Class: I18n::Alchemy::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_alchemy/attribute.rb

Instance Method Summary collapse

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

#readObject



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