class Lab42::Curry::Currier
Attributes
arg_compiler[R]
context[R]
ct_args[R]
ct_blk[R]
ct_kwds[R]
mthd[R]
Public Class Methods
new(method_or_name, ct_args, ct_kwds, context:, allow_override: false, &ct_blk)
click to toggle source
# File lib/lab42/curry/currier.rb, line 38 def initialize(method_or_name, ct_args, ct_kwds, context:, allow_override: false, &ct_blk) @allow_override = allow_override @context = context @ct_args = ct_args @ct_blk = ct_blk @ct_kwds = ct_kwds @arg_compiler = ArgCompiler.new(ct_args, ct_kwds, allow_override: allow_override, &ct_blk) _init_mthd method_or_name end
Public Instance Methods
_bind_and_call(args, kwds, blk)
click to toggle source
# File lib/lab42/curry/currier.rb, line 17 def _bind_and_call(args, kwds, blk) receiver = args.shift mthd = @mthd.bind(receiver) rt_args, rt_kwds, rt_blk = arg_compiler.compile(args, kwds, blk) if rt_blk mthd.(*rt_args, **rt_kwds, &rt_blk) else mthd.(*rt_args, **rt_kwds) end end
_just_call(args, kwds, blk)
click to toggle source
# File lib/lab42/curry/currier.rb, line 28 def _just_call(args, kwds, blk) rt_args, rt_kwds, rt_blk = arg_compiler.compile(args, kwds, blk) if rt_blk mthd.(*rt_args, **rt_kwds, &rt_blk) else mthd.(*rt_args, **rt_kwds) end end
call(*args, **kwds, &blk)
click to toggle source
# File lib/lab42/curry/currier.rb, line 8 def call(*args, **kwds, &blk) case mthd when UnboundMethod _bind_and_call(args, kwds, blk) else _just_call(args, kwds, blk) end end
Private Instance Methods
_init_mthd(method_or_name)
click to toggle source
# File lib/lab42/curry/currier.rb, line 50 def _init_mthd method_or_name @mthd = case method_or_name when Symbol context.method(method_or_name) else method_or_name end end