Class: DataMapper::Resource::State::Dirty
Overview
a persisted/dirty resource
Instance Attribute Summary
#resource
Instance Method Summary
collapse
Methods inherited from Persisted
#get
#get, #initialize
Methods included from Equalizer
#equalize
Instance Method Details
#commit ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/dm-core/resource/state/dirty.rb', line 18
def commit
remove_from_identity_map
set_child_keys
return self unless valid_attributes?
update_resource
reset_original_attributes
reset_resource_key
Clean.new(resource)
ensure
add_to_identity_map
end
|
#delete ⇒ Object
13
14
15
16
|
# File 'lib/dm-core/resource/state/dirty.rb', line 13
def delete
reset_resource
Deleted.new(resource)
end
|
#original_attributes ⇒ Object
35
36
37
|
# File 'lib/dm-core/resource/state/dirty.rb', line 35
def original_attributes
@original_attributes ||= {}
end
|
#rollback ⇒ Object
30
31
32
33
|
# File 'lib/dm-core/resource/state/dirty.rb', line 30
def rollback
reset_resource
Clean.new(resource)
end
|
#set(subject, value) ⇒ Object
7
8
9
10
11
|
# File 'lib/dm-core/resource/state/dirty.rb', line 7
def set(subject, value)
track(subject, value)
super
original_attributes.empty? ? Clean.new(resource) : self
end
|