Class: Pipetree::Function::Insert

Inherits:
Object
  • Object
show all
Defined in:
lib/pipetree/insert.rb

Defined Under Namespace

Modules: Macros

Instance Method Summary collapse

Instance Method Details

#call(arr, func, options) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/pipetree/insert.rb', line 3

def call(arr, func, options)
  # arr = arr.dup
  operations = [:delete, :replace, :before, :after, :append, :prepend]

  # replace!(arr, options[:replace], func)
  options.keys.reverse.each { |k| operations.include?(k) and return send("#{k}!", arr, options[k], func) }

  raise "[Pipetree] Unknown command #{options.inspect}" # TODO: test.
  # arr
end