module ProcUtils

Constants

ALL
SYM
VERSION

Public Class Methods

bind(subject, receiver, *bound_args) click to toggle source
# File lib/proc_utils.rb, line 16
def bind(subject, receiver, *bound_args)
  proc { |*args| subject.call(receiver, *bound_args, *args) }
end
compose(subject, other) click to toggle source
# File lib/proc_utils.rb, line 28
def compose(subject, other)
  proc { |*args| subject.call(*other.call(*args)) }
end
flip(subject) click to toggle source
# File lib/proc_utils.rb, line 20
def flip(subject)
  proc { |*args| subject.call(*args.reverse) }
end
memoize(subject) click to toggle source
# File lib/proc_utils.rb, line 32
def memoize(subject)
  cache = {}
  proc { |*args| cache[args] ||= subject.call(*args) }
end
once(subject) click to toggle source
# File lib/proc_utils.rb, line 37
def once(subject)
  cache, called = nil, false

  proc do |*args|
    cache, called = subject.call(*args), true unless called
    cache
  end
end
partial(subject, *bound_args) click to toggle source
# File lib/proc_utils.rb, line 8
def partial(subject, *bound_args)
  proc { |receiver, *args| subject.call(receiver, *bound_args, *args) }
end
partial_right(subject, *bound_args) click to toggle source
# File lib/proc_utils.rb, line 12
def partial_right(subject, *bound_args)
  proc { |receiver, *args| subject.call(receiver, *args, *bound_args) }
end
wrap(subject, other) click to toggle source
# File lib/proc_utils.rb, line 24
def wrap(subject, other)
  proc { |*args| subject.call(other, *args) }
end