Module: Carrier::Rails::Helpers

Defined in:
lib/carrier/rails/helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
# File 'lib/carrier/rails/helpers.rb', line 5

def self.included base
  base.send :helper_method, :unread_messages, :all_messages
  base.send :helper_method, :current_user
  base.send :helper_method, :prefix_for_messages
  base.send :helper_method, :find_method_for_user
end

Instance Method Details

#all_messagesObject



29
30
31
# File 'lib/carrier/rails/helpers.rb', line 29

def all_messages
  @all_messages ||= Carrier::Message.for_or_by(current_user)
end

#current_userObject



24
25
26
27
# File 'lib/carrier/rails/helpers.rb', line 24

def current_user
  raise "Define #current_user method!" if !defined?(super)
  super
end

#find_method_for_userObject



12
13
14
# File 'lib/carrier/rails/helpers.rb', line 12

def find_method_for_user
  :"find_by_#{user_key_attr}"
end

#prefix_for_messagesObject



20
21
22
# File 'lib/carrier/rails/helpers.rb', line 20

def prefix_for_messages
  carrier_config.routes.prefix_for_messages 
end

#unread_messagesObject



33
34
35
# File 'lib/carrier/rails/helpers.rb', line 33

def unread_messages
  @unread_messages ||= Carrier::Message.unread(current_user)
end

#user_key_attrObject



16
17
18
# File 'lib/carrier/rails/helpers.rb', line 16

def user_key_attr
  carrier_config.user.key_attr
end