Module: Toy::Dirty

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Dirty, Attributes, Cloneable
Included in:
Object
Defined in:
lib/toy/dirty.rb

Instance Method Summary collapse

Methods included from Attributes

#[], #[]=, #attributes, #attributes=, #initialize

Instance Method Details

#initialize_copyObject



8
9
10
11
12
13
# File 'lib/toy/dirty.rb', line 8

def initialize_copy(*)
  super.tap do
    @previously_changed = {}
    @changed_attributes = {}
  end
end

#write_attribute(name, value) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/toy/dirty.rb', line 15

def write_attribute(name, value)
  @attributes ||= {}
  name    = name.to_s
  current = read_attribute(name)
  attribute_will_change!(name) if current != value
  super
end