Class: Layer::Patch::Base

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/layer/patch/base.rb

Direct Known Subclasses

Array, Hash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(patch, object) ⇒ Base

Returns a new instance of Base



7
8
9
10
# File 'lib/layer/patch/base.rb', line 7

def initialize(patch, object)
  @patch = patch
  super(prepare_base(object))
end

Instance Attribute Details

#patchObject (readonly)

Returns the value of attribute patch



5
6
7
# File 'lib/layer/patch/base.rb', line 5

def patch
  @patch
end

Instance Method Details

#wrap(property, object) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/layer/patch/base.rb', line 12

def wrap(property, object)
  case object
  when ::Array
    Layer::Patch::Array.new(patch.nested(property), object)
  when ::Hash
    Layer::Patch::Hash.new(patch.nested(property), object)
  else
    object
  end
end