Class: HstoreTranslations::TranslationsLookup
- Inherits:
-
Object
- Object
- HstoreTranslations::TranslationsLookup
- Defined in:
- lib/hstore_translations/translations_lookup.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model, attribute, locale = nil) ⇒ TranslationsLookup
constructor
A new instance of TranslationsLookup.
- #value ⇒ Object
Constructor Details
#initialize(model, attribute, locale = nil) ⇒ TranslationsLookup
Returns a new instance of TranslationsLookup.
5 6 7 8 |
# File 'lib/hstore_translations/translations_lookup.rb', line 5 def initialize(model, attribute, locale = nil) @model, @attribute, @locale = model, attribute, locale @locale = locale end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
3 4 5 |
# File 'lib/hstore_translations/translations_lookup.rb', line 3 def attribute @attribute end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/hstore_translations/translations_lookup.rb', line 3 def model @model end |
Instance Method Details
#value ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hstore_translations/translations_lookup.rb', line 10 def value if @locale try_locale(@locale) else fallbacks.inject(nil) do |_, locale| value = try_locale(locale) return value if value.present? end end end |