class Layer::Patch
Attributes
property[R]
Public Class Methods
new(property = nil, parent = nil)
click to toggle source
# File lib/layer/patch.rb, line 7 def initialize(property = nil, parent = nil) @property = property @parent = parent end
Public Instance Methods
add(property = nil, value)
click to toggle source
# File lib/layer/patch.rb, line 12 def add(property = nil, value) operation(:add, property, value: value) end
add_index(property = nil, index, value)
click to toggle source
# File lib/layer/patch.rb, line 16 def add_index(property = nil, index, value) operation(:add, property, index: index, value: value) end
delete(property)
click to toggle source
# File lib/layer/patch.rb, line 36 def delete(property) operation(:delete, property) end
nested(property)
click to toggle source
# File lib/layer/patch.rb, line 40 def nested(property) self.class.new(property, self) end
operations()
click to toggle source
# File lib/layer/patch.rb, line 44 def operations @operations ||= @parent ? @parent.operations : [] end
remove(property = nil, value)
click to toggle source
# File lib/layer/patch.rb, line 20 def remove(property = nil, value) operation(:remove, property, value: value) end
remove_index(property = nil, index)
click to toggle source
# File lib/layer/patch.rb, line 24 def remove_index(property = nil, index) operation(:remove, property, index: index) end
replace(property = nil, value)
click to toggle source
# File lib/layer/patch.rb, line 32 def replace(property = nil, value) operation(:replace, property, value: value) end
reset()
click to toggle source
# File lib/layer/patch.rb, line 48 def reset @parent ? parent.reset : operations.clear end
set(property = nil, value)
click to toggle source
# File lib/layer/patch.rb, line 28 def set(property = nil, value) operation(:set, property, value: value) end
Private Instance Methods
expand_property(property)
click to toggle source
# File lib/layer/patch.rb, line 60 def expand_property(property) [@parent && @parent.property, @property, property].compact.join('.') end
operation(type, property = nil, options = {})
click to toggle source
# File lib/layer/patch.rb, line 56 def operation(type, property = nil, options = {}) operations << options.merge(operation: type.to_s, property: expand_property(property)) end