module DataProcessor::Manipulate

Public Instance Methods

manipulate(path, override=false) { |obj, parent_obj| ... } click to toggle source
# File lib/data_processor/manipulate.rb, line 4
def manipulate(path, override=false)
  obj, parent_obj = traverse_path(@data, path)

  # execute block with object and parent object as params
  # ie. if the object is found
  # + override object with return value of block if needed
  if block_given? && obj
    block_return_value = yield(obj, parent_obj)
    parent_obj[path.split("/").last] = block_return_value if override
  end
end