Module: Expansion::ActiveRecord::InstanceMethods
- Defined in:
- lib/activerecord/extensions.rb
Instance Method Summary collapse
- #expansion_attributes ⇒ Object
- #expansion_value(attribute, value = nil, options = {}) ⇒ Object (also: #expansion_values)
Instance Method Details
#expansion_attributes ⇒ Object
26 27 28 29 30 |
# File 'lib/activerecord/extensions.rb', line 26 def expansion_attributes self.class.expansion_attributes.each_with_object({}) do |attribute, hash| hash[attribute.name] = attribute.values_for( self ) end end |
#expansion_value(attribute, value = nil, options = {}) ⇒ Object Also known as: expansion_values
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/activerecord/extensions.rb', line 32 def expansion_value attribute, value=nil, ={} if value Expansion::Value.new do |v| v.owner = self v.attribute = attribute v.value = value v.note = [:note] v.date = [:date] end.save! else attribute.values_for( self ) end end |