Class: DataMapper::Resource::State

Inherits:
Object
  • Object
show all
Extended by:
Equalizer
Defined in:
lib/dm-core/resource/state.rb,
lib/dm-core/resource/state/clean.rb,
lib/dm-core/resource/state/dirty.rb,
lib/dm-core/resource/state/deleted.rb,
lib/dm-core/resource/state/immutable.rb,
lib/dm-core/resource/state/persisted.rb,
lib/dm-core/resource/state/transient.rb

Overview

the state of the resource (abstract)

Direct Known Subclasses

Immutable, Persisted, Transient

Defined Under Namespace

Classes: Clean, Deleted, Dirty, Immutable, Persisted, Transient

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Equalizer

equalize

Constructor Details

#initialize(resource) ⇒ State

Returns a new instance of State.



12
13
14
15
# File 'lib/dm-core/resource/state.rb', line 12

def initialize(resource)
  @resource = resource
  @model    = resource.model
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



10
11
12
# File 'lib/dm-core/resource/state.rb', line 10

def resource
  @resource
end

Instance Method Details

#commitObject

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/dm-core/resource/state.rb', line 30

def commit
  raise NotImplementedError, "#{self.class}#commit should be implemented"
end

#deleteObject

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/dm-core/resource/state.rb', line 26

def delete
  raise NotImplementedError, "#{self.class}#delete should be implemented"
end

#get(subject, *args) ⇒ Object



17
18
19
# File 'lib/dm-core/resource/state.rb', line 17

def get(subject, *args)
  subject.get(resource, *args)
end

#rollbackObject

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/dm-core/resource/state.rb', line 34

def rollback
  raise NotImplementedError, "#{self.class}#rollback should be implemented"
end

#set(subject, value) ⇒ Object



21
22
23
24
# File 'lib/dm-core/resource/state.rb', line 21

def set(subject, value)
  subject.set(resource, value)
  self
end