Module: ValueObject::Attribute::ClassMethods
- Defined in:
- lib/value_object/attribute.rb
Instance Method Summary collapse
Instance Method Details
#value_attribute(attr_name, klass) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/value_object/attribute.rb', line 8 def value_attribute(attr_name, klass) id_attr = "#{attr_name}_id" define_method attr_name do klass.find self.public_send(id_attr) end define_method "#{attr_name}=" do |obj| self.public_send("#{id_attr}=", obj.key) end end |