Module: I18n::Message::Cascade
- Defined in:
- lib/i18n/message/cascade.rb
Overview
Encapsulates the pattern of looking up a translation key from several scopes.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/i18n/message/cascade.rb', line 10 def self.included(base) base.class_eval do cattr_accessor :cascade_options # FIXME use inheritable_attribute_accessor self. = { :step => 2, :skip_root => true } end end |
Instance Method Details
#options ⇒ Object
17 18 19 |
# File 'lib/i18n/message/cascade.rb', line 17 def super.update(:cascade => self.class.) end |
#scope ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/i18n/message/cascade.rb', line 21 def scope scopes = [super] + Array(self.class.[:scopes]).map do |scope| if [scope] value = [scope] value = value.class.name unless value.is_a?(String) || value.is_a?(Symbol) "#{scope}s.#{value.to_s.underscore}" end end scopes.compact.join('.') end |