Module: UserNotification::ViewHelpers

Defined in:
lib/user_notification/utility/view_helpers.rb

Overview

Module extending ActionView::Base and adding ‘render_notification` helper.

Instance Method Summary collapse

Instance Method Details

#render_notification(notifications, options = {}) ⇒ Object Also known as: render_notifications

View helper for rendering an notification, calls Notification#render internally.



6
7
8
9
10
11
12
13
14
# File 'lib/user_notification/utility/view_helpers.rb', line 6

def render_notification notifications, options = {}
  if notifications.is_a? UserNotification::Notification
    notifications.render self, options
  elsif notifications.respond_to?(:map)
    # depend on ORMs to fetch as needed
    # maybe we can support Postgres streaming with this?
    notifications.map {|notification| notification.render self, options.dup }.join.html_safe
  end
end

#single_content_for(name, content = nil, &block) ⇒ Object

Helper for setting content_for in notification partial, needed to flush remains in between partial renders.



19
20
21
22
# File 'lib/user_notification/utility/view_helpers.rb', line 19

def single_content_for(name, content = nil, &block)
  @view_flow.set(name, ActiveSupport::SafeBuffer.new)
  content_for(name, content, &block)
end