Sha256: 0a23f255201451a40140c8146b76d3115ddd0e4b28bef16dafdbe9d93b8e1f58

Contents?: true

Size: 478 Bytes

Versions: 2

Compression:

Stored size: 478 Bytes

Contents

class DataProcessor
  module Manipulate

    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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data_processor-0.2.1 lib/data_processor/manipulate.rb
data_processor-0.2.0 lib/data_processor/manipulate.rb