module DenshobatoChatPanel::ChatPanelHelper
Constants
- DEFAULT_EMAIL
class User < ActiveRecord::Base
def full_name "#{first_name}", #{last_name} end def image user_avatar.url end
end
Public Instance Methods
full_name()
click to toggle source
# File lib/denshobato_chat_panel/chat_panel_helper.rb, line 18 def full_name # Set up default name for chat panel # By default class name will be used, e.g => User self.class.name.titleize end
image()
click to toggle source
# File lib/denshobato_chat_panel/chat_panel_helper.rb, line 25 def image # Show gravatar image # Email field is expected by default for gravatar and for messagable model. # If a model doesn`t have email field, send to method 'default' email, to show default gravatar gravatar_image = Digest::MD5.hexdigest(email.downcase) email == DEFAULT_EMAIL ? gravatar(gravatar_image, '?d=mm') : gravatar(gravatar_image) end
method_missing(method, *_args)
click to toggle source
# File lib/denshobato_chat_panel/chat_panel_helper.rb, line 34 def method_missing(method, *_args) DEFAULT_EMAIL if method.to_s == 'email' end
Private Instance Methods
gravatar(email, args = nil)
click to toggle source
# File lib/denshobato_chat_panel/chat_panel_helper.rb, line 40 def gravatar(email, args = nil) "https://secure.gravatar.com/avatar/#{email}/#{args}" end