17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/gearbox/mixins/semantic_accessors.rb', line 17
def attribute(name, opts={})
opts = opts.merge(:name => name)
define_method(name) do
attribute_definitions[name] ||= Attribute.new(opts)
attribute_definitions[name].to_value
end
define_method("#{name}=") do |value|
@previously_changed = changes
attribute_definitions[name] ||= Attribute.new(opts)
old_value = attribute_definitions[name].get
new_value = attribute_definitions[name].set(value)
name_will_change! unless new_value == old_value
end
attributes[name] = opts
define_attribute_method(name)
end
|