Module: Carrier::Rails::Helpers
- Defined in:
- lib/carrier/rails/helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #all_messages ⇒ Object
- #current_user ⇒ Object
- #find_method_for_user ⇒ Object
- #prefix_for_messages ⇒ Object
- #unread_messages ⇒ Object
- #user_key_attr ⇒ Object
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_messages ⇒ Object
29 30 31 |
# File 'lib/carrier/rails/helpers.rb', line 29 def @all_messages ||= Carrier::Message.for_or_by(current_user) end |
#current_user ⇒ Object
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_user ⇒ Object
12 13 14 |
# File 'lib/carrier/rails/helpers.rb', line 12 def find_method_for_user :"find_by_#{user_key_attr}" end |
#prefix_for_messages ⇒ Object
20 21 22 |
# File 'lib/carrier/rails/helpers.rb', line 20 def carrier_config.routes. end |
#unread_messages ⇒ Object
33 34 35 |
# File 'lib/carrier/rails/helpers.rb', line 33 def @unread_messages ||= Carrier::Message.unread(current_user) end |
#user_key_attr ⇒ Object
16 17 18 |
# File 'lib/carrier/rails/helpers.rb', line 16 def user_key_attr carrier_config.user.key_attr end |