Module: Toy::DirtyStore

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Dirty, Persistence, Querying, Reloadable
Included in:
Store
Defined in:
lib/toy/dirty_store.rb

Instance Method Summary collapse

Methods included from Persistence

#adapter, #delete, #destroy, #destroyed?, #initialize, #initialize_copy, #new_record?, #persist, #persisted?, #persisted_attributes, #persisted_id, #update_attributes

Instance Method Details

#initialize_from_databaseObject



9
10
11
12
13
14
15
16
# File 'lib/toy/dirty_store.rb', line 9

def initialize_from_database(*)
  super

  @previously_changed = {}
  @changed_attributes.clear if @changed_attributes

  self
end

#reloadObject



18
19
20
21
22
23
# File 'lib/toy/dirty_store.rb', line 18

def reload
  super.tap do
    @previously_changed = {}
    @changed_attributes = {}
  end
end

#save(options = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/toy/dirty_store.rb', line 25

def save(options={})
  super.tap do
    @previously_changed = changes
    @changed_attributes.clear if @changed_attributes
  end
end