Class: I18n::Alchemy::Attribute
- Inherits:
-
Object
- Object
- I18n::Alchemy::Attribute
- Defined in:
- lib/i18n_alchemy/attribute.rb
Instance Method Summary collapse
-
#initialize(target, attribute, parser) ⇒ Attribute
constructor
A new instance of Attribute.
- #parse(value) ⇒ Object
- #read ⇒ Object
- #write(value) ⇒ Object
Constructor Details
#initialize(target, attribute, parser) ⇒ Attribute
Returns a new instance of Attribute.
4 5 6 7 8 |
# File 'lib/i18n_alchemy/attribute.rb', line 4 def initialize(target, attribute, parser) @target = target @attribute = attribute @parser = parser end |
Instance Method Details
#parse(value) ⇒ Object
18 19 20 |
# File 'lib/i18n_alchemy/attribute.rb', line 18 def parse(value) @parser.parse(value) end |
#read ⇒ Object
10 11 12 |
# File 'lib/i18n_alchemy/attribute.rb', line 10 def read @parser.localize(@target.send(@attribute)) end |
#write(value) ⇒ Object
14 15 16 |
# File 'lib/i18n_alchemy/attribute.rb', line 14 def write(value) @target.send(:"#{@attribute}=", parse(value)) end |