Class: Traco::LocalizedReader
- Inherits:
-
Object
- Object
- Traco::LocalizedReader
- Defined in:
- lib/traco/localized_reader.rb
Instance Method Summary collapse
-
#initialize(record, attribute, options) ⇒ LocalizedReader
constructor
A new instance of LocalizedReader.
- #value ⇒ Object
Constructor Details
#initialize(record, attribute, options) ⇒ LocalizedReader
Returns a new instance of LocalizedReader.
3 4 5 6 7 |
# File 'lib/traco/localized_reader.rb', line 3 def initialize(record, attribute, ) @record = record @attribute = attribute @fallback = [:fallback] end |
Instance Method Details
#value ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/traco/localized_reader.rb', line 9 def value locales_to_try.each do |locale| value = @record.send("#{@attribute}_#{Traco.locale_suffix(locale)}") return value if value.present? end nil end |