Class: Pipetree::Function::Insert

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

Constant Summary collapse

Operations =
[:delete, :replace, :before, :after, :append, :prepend]

Instance Method Summary collapse

Instance Method Details

#call(arr, operation, *args) ⇒ Object

DISCUSS: all methods write to original array.



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

def call(arr, operation, *args)
  # arr = arr.dup
  raise "[Pipetree] Unknown Insert operation #{args.inspect}" unless Operations.include?(operation)

  send("#{operation}!", arr, *args) # replace!(arr, Old, New)

  # arr
end