module Lab42::Function::MakeFunction

Public Instance Methods

make_function(from) click to toggle source
# File lib/lab42/function/make_function.rb, line 5
def make_function from
  case from
  when Symbol
    Lab42::Function.free_receiver from
  when Array
    make_function_from_ary from
  when Proc, Method
    Lab42::Function.new from, from.arity
  when Lab42::Function
    from
  else
    raise ArgumentError, "cannot make a behavior from #{from.inspect}"
  end
end
make_function_from_ary(ary) click to toggle source
# File lib/lab42/function/make_function.rb, line 20
def make_function_from_ary ary
  case ary.first
  when Symbol
    Lab42::Function.free_receiver( *ary )
  else
    Lab42::Function.partial( *ary )
  end
end