Module: Notifiable::Helpers::NotifiableHelpers
- Defined in:
- lib/notifiable/helpers/notifiable_helpers.rb
Instance Method Summary collapse
- #notifications(options = {}) ⇒ Object
- #notify_for(obj, options = {}) ⇒ Object
- #notify_msg(message, options = {}) ⇒ Object
- #static_notification(level, header, options = {}, &block) ⇒ Object
Instance Method Details
#notifications(options = {}) ⇒ Object
22 23 24 |
# File 'lib/notifiable/helpers/notifiable_helpers.rb', line 22 def notifications(={}) Notification.global.viewable.map {|msg| notify_msg(msg, )}.join("\n") end |
#notify_for(obj, options = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/notifiable/helpers/notifiable_helpers.rb', line 16 def notify_for(obj, ={}) = obj.notificaions.select(&:viewable?). map {|msg| notify_msg(msg, )} .join("\n") end |
#notify_msg(message, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/notifiable/helpers/notifiable_helpers.rb', line 4 def notify_msg(, ={}) header = header_div(.header, .level) body = . = {:class => "notify #{.level}", :id => "notification_#{.id}"}.merge() if .dismissable? body += content_tag(:p, link_to_remote("Dismiss", :url => {:controller => 'notifiable/notifications', :action => 'dismiss', :id => .id})) end content_tag(:div, header + body, ) end |
#static_notification(level, header, options = {}, &block) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/notifiable/helpers/notifiable_helpers.rb', line 26 def static_notification(level, header, ={}, &block) header = header_div(header, level) body = capture(&block) concat(content_tag(:div, header + body, {:class => "notify #{level}"}.merge()), block.binding) end |