module Necklace

Constants

ARG_INSERTION_ORDER

Public Instance Methods

_call(method, result, order) click to toggle source
# File lib/necklace.rb, line 20
def _call(method, result, order)
  method = [method].flatten
  args = method.insert(ARG_INSERTION_ORDER[order], result)
  send(*args)
end
through(enumerable, methods) click to toggle source
# File lib/necklace.rb, line 4
def through(enumerable, methods)
  through_last(enumerable, methods)
end
through_first(enumerable, methods) click to toggle source
# File lib/necklace.rb, line 8
def through_first(enumerable, methods)
  methods.reduce(enumerable) do |result, method|
    _call(method, result, :first)
  end
end
through_last(enumerable, methods) click to toggle source
# File lib/necklace.rb, line 14
def through_last(enumerable, methods)
  methods.reduce(enumerable) do |result, method|
    _call(method, result, :last)
  end
end