Module: Expansion::ActiveRecord::InstanceMethods

Defined in:
lib/activerecord/extensions.rb

Instance Method Summary collapse

Instance Method Details

#expansion_attributesObject



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, options={}
  if value
    Expansion::Value.new do |v|
      v.owner     = self
      v.attribute = attribute
      v.value     = value
      v.note      = options[:note]
      v.date      = options[:date]
    end.save!
  else
    attribute.values_for( self )
  end
end