Class: Udongo::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/udongo/notification.rb

Instance Method Summary collapse

Constructor Details

#initialize(notice) ⇒ Notification

Returns a new instance of Notification.



2
3
4
# File 'lib/udongo/notification.rb', line 2

def initialize(notice)
  @notice = notice
end

Instance Method Details

#build_hash(actor) ⇒ Object



6
7
8
# File 'lib/udongo/notification.rb', line 6

def build_hash(actor)
  { actor: I18n.t("b.#{actor}") }
end

#labelObject



10
11
12
# File 'lib/udongo/notification.rb', line 10

def label
  "b.msg.#{@notice}"
end

#translate(vars = nil) ⇒ Object



14
15
16
17
18
# File 'lib/udongo/notification.rb', line 14

def translate(vars = nil)
  return I18n.t(label) if vars.blank?
  vars = build_hash(vars) unless vars.is_a?(Hash)
  I18n.t(label, vars)
end