Module: UserNotif::ViewHelpers

Includes:
ActionView::Context, ActionView::Helpers
Defined in:
lib/user_notif/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#list_user_notifs(notifs = nil, small = true) ⇒ Object



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

def list_user_notifs(notifs = nil, small = true)
  return unless notifs
  output = ''

  notifs.each { |n| output << user_notif(n, small) }

  wrap output
end

#notif_badge(notifs = nil) ⇒ Object



21
22
23
24
# File 'lib/user_notif/view_helpers.rb', line 21

def notif_badge(notifs = nil)
  nb = notifs.count
  nb == 0 ? '' : "<span class=\"notif-badge\">#{nb}</span>".html_safe
end

#user_notif(notif, small = true) ⇒ Object



15
16
17
18
19
# File 'lib/user_notif/view_helpers.rb', line 15

def user_notif(notif, small = true)
  @notif = notif
  @target = notif.target
  render("notifs/#{small ? 'small' : 'full'}/#{notif.template_name}")
end