Class: Udongo::Notification
- Inherits:
-
Object
- Object
- Udongo::Notification
- Defined in:
- lib/udongo/notification.rb
Instance Method Summary collapse
- #build_hash(actor) ⇒ Object
-
#initialize(notice) ⇒ Notification
constructor
A new instance of Notification.
- #label ⇒ Object
- #translate(vars = nil) ⇒ Object
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 |
#label ⇒ Object
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 |