Sha256: a358e35ba68f496171bf638d223ac28bfd67b82f3e380f9fb4e5c162dc1b0f6b

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

module NotificationRendererHelper

    def render_notification notification, renderer = NotificationRenderer.configuration.default_renderer, attribute = nil, notifications_count = nil
        notification.update_attributes read: true if NotificationRenderer.configuration.auto_read
        render "notifications/#{notification.type}/#{renderer}", notification: notification, attribute: attribute, notifications_count: notifications_count
    end

    def render_notifications notifications, renderer = NotificationRenderer.configuration.default_renderer
        content_tag :div, class: 'notification-renderer notifications' do
            notifications.each do |notification|
                render_notification notification, renderer
            end
        end
    end

    def render_notifications_grouped notifications, group_by, renderer = NotificationRenderer.configuration.default_renderer
        content_tag :div, class: 'notification-renderer notifications' do
            notifications.grouping(group_by)&.each do |attribute, notifications|
                render_notification notifications.last, renderer, attribute, notifications.count
            end
        end
    end

    def notification_grouped?
        local_assigns[:attribute]
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
notification-renderer-1.2.3 app/helpers/notification_renderer_helper.rb