Class: AASM::Localizer

Inherits:
Object
  • Object
show all
Defined in:
lib/alexrevin-aasm_numerical/localizer.rb

Instance Method Summary collapse

Instance Method Details

#human_event_name(klass, event) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/alexrevin-aasm_numerical/localizer.rb', line 2

def human_event_name(klass, event)
  defaults = ancestors_list(klass).map do |ancestor|
    :"#{i18n_scope(klass)}.events.#{i18n_klass(ancestor)}.#{event}"
  end << event.to_s.humanize

  I18n.translate(defaults.shift, :default => defaults, :raise => true)
end

#human_state(obj) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/alexrevin-aasm_numerical/localizer.rb', line 10

def human_state(obj)
  klass = obj.class
  defaults = ancestors_list(klass).map do |ancestor|
    :"#{i18n_scope(klass)}.attributes.#{i18n_klass(ancestor)}.#{klass.aasm_column}.#{obj.aasm_current_state}"
  end << obj.aasm_current_state.to_s.humanize

  I18n.translate(defaults.shift, :default => defaults, :raise => true)
end