Class: Layer::Patch
- Inherits:
-
Object
show all
- Defined in:
- lib/layer/patch.rb,
lib/layer/patch/base.rb,
lib/layer/patch/hash.rb,
lib/layer/patch/array.rb
Defined Under Namespace
Classes: Array, Base, Hash
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(property = nil, parent = nil) ⇒ Patch
Returns a new instance of Patch.
7
8
9
10
|
# File 'lib/layer/patch.rb', line 7
def initialize(property = nil, parent = nil)
@property = property
@parent = parent
end
|
Instance Attribute Details
#property ⇒ Object
Returns the value of attribute property.
52
53
54
|
# File 'lib/layer/patch.rb', line 52
def property
@property
end
|
Instance Method Details
#add(property = nil, value) ⇒ Object
12
13
14
|
# File 'lib/layer/patch.rb', line 12
def add(property = nil, value)
operation(:add, property, value: value)
end
|
#add_index(property = nil, index, value) ⇒ Object
16
17
18
|
# File 'lib/layer/patch.rb', line 16
def add_index(property = nil, index, value)
operation(:add, property, index: index, value: value)
end
|
#delete(property) ⇒ Object
36
37
38
|
# File 'lib/layer/patch.rb', line 36
def delete(property)
operation(:delete, property)
end
|
#nested(property) ⇒ Object
40
41
42
|
# File 'lib/layer/patch.rb', line 40
def nested(property)
self.class.new(property, self)
end
|
#operations ⇒ Object
44
45
46
|
# File 'lib/layer/patch.rb', line 44
def operations
@operations ||= @parent ? @parent.operations : []
end
|
#remove(property = nil, value) ⇒ Object
20
21
22
|
# File 'lib/layer/patch.rb', line 20
def remove(property = nil, value)
operation(:remove, property, value: value)
end
|
#remove_index(property = nil, index) ⇒ Object
24
25
26
|
# File 'lib/layer/patch.rb', line 24
def remove_index(property = nil, index)
operation(:remove, property, index: index)
end
|
#replace(property = nil, value) ⇒ Object
32
33
34
|
# File 'lib/layer/patch.rb', line 32
def replace(property = nil, value)
operation(:replace, property, value: value)
end
|
#reset ⇒ Object
48
49
50
|
# File 'lib/layer/patch.rb', line 48
def reset
@parent ? parent.reset : operations.clear
end
|
#set(property = nil, value) ⇒ Object
28
29
30
|
# File 'lib/layer/patch.rb', line 28
def set(property = nil, value)
operation(:set, property, value: value)
end
|