Class: DataMapper::Resource::PersistenceState::Clean

Inherits:
Persisted show all
Defined in:
lib/dm-core/resource/persistence_state/clean.rb

Overview

a persisted/unmodified resource

Instance Attribute Summary

Attributes inherited from DataMapper::Resource::PersistenceState

#resource

Instance Method Summary collapse

Methods inherited from Persisted

#get

Methods inherited from DataMapper::Resource::PersistenceState

#get, #initialize

Methods included from Equalizer

#equalize

Constructor Details

This class inherits a constructor from DataMapper::Resource::PersistenceState

Instance Method Details

#commitObject



23
24
25
# File 'lib/dm-core/resource/persistence_state/clean.rb', line 23

def commit
  self
end

#deleteObject



19
20
21
# File 'lib/dm-core/resource/persistence_state/clean.rb', line 19

def delete
  Deleted.new(resource)
end

#rollbackObject



27
28
29
# File 'lib/dm-core/resource/persistence_state/clean.rb', line 27

def rollback
  self
end

#set(subject, value) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/dm-core/resource/persistence_state/clean.rb', line 7

def set(subject, value)
  if not_modified?(subject, value)
    self
  else
    # assign to persistence_state so that if Dirty#set calls
    # a Relationship#set, which modifies a Property, the same
    # Dirty state instance will be reused.
    state = resource.persistence_state = Dirty.new(resource)
    state.set(subject, value)
  end
end