Module: ActiveRecord::Diff::ClassMethods

Defined in:
lib/generators/somatics/install/templates/lib/active_record/diff.rb

Instance Method Summary collapse

Instance Method Details

#diff(*attrs) ⇒ Object



4
5
6
# File 'lib/generators/somatics/install/templates/lib/active_record/diff.rb', line 4

def diff(*attrs)
  write_inheritable_attribute(:diff_attrs, attrs)
end

#diff_attrsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/generators/somatics/install/templates/lib/active_record/diff.rb', line 8

def diff_attrs
  attrs = read_inheritable_attribute(:diff_attrs)
    
  if attrs.nil?
    content_columns.map { |column| column.name }
  elsif attrs.length == 1 && Hash === attrs.first
    columns = content_columns.map { |column| column.name.to_sym }
    
    columns + (attrs.first[:include] || []) - (attrs.first[:exclude] || [])
  else
    attrs
  end
end