Class: DataMapper::Resource::State::Immutable
Overview
a not-persisted/unmodifiable resource
Instance Attribute Summary
#resource
Instance Method Summary
collapse
#initialize
Methods included from Equalizer
#equalize
Instance Method Details
#commit ⇒ Object
23
24
25
|
# File 'lib/dm-core/resource/state/immutable.rb', line 23
def commit
self
end
|
#delete ⇒ Object
19
20
21
|
# File 'lib/dm-core/resource/state/immutable.rb', line 19
def delete
raise ImmutableError, 'Immutable resource cannot be deleted'
end
|
#get(subject, *args) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/dm-core/resource/state/immutable.rb', line 7
def get(subject, *args)
unless subject.loaded?(resource) || subject.kind_of?(Associations::Relationship)
raise ImmutableError, 'Immutable resource cannot be lazy loaded'
end
super
end
|
#rollback ⇒ Object
27
28
29
|
# File 'lib/dm-core/resource/state/immutable.rb', line 27
def rollback
self
end
|
#set(subject, value) ⇒ Object
15
16
17
|
# File 'lib/dm-core/resource/state/immutable.rb', line 15
def set(subject, value)
raise ImmutableError, 'Immutable resource cannot be modified'
end
|