Class: Lab42::Curry::Currier
- Inherits:
-
Object
- Object
- Lab42::Curry::Currier
- Defined in:
- lib/lab42/curry/currier.rb
Instance Attribute Summary collapse
-
#arg_compiler ⇒ Object
readonly
Returns the value of attribute arg_compiler.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#ct_args ⇒ Object
readonly
Returns the value of attribute ct_args.
-
#ct_blk ⇒ Object
readonly
Returns the value of attribute ct_blk.
-
#ct_kwds ⇒ Object
readonly
Returns the value of attribute ct_kwds.
-
#mthd ⇒ Object
readonly
Returns the value of attribute mthd.
Instance Method Summary collapse
- #_bind_and_call(args, kwds, blk) ⇒ Object
- #_just_call(args, kwds, blk) ⇒ Object
- #call(*args, **kwds, &blk) ⇒ Object
Instance Attribute Details
#arg_compiler ⇒ Object (readonly)
Returns the value of attribute arg_compiler.
6 7 8 |
# File 'lib/lab42/curry/currier.rb', line 6 def arg_compiler @arg_compiler end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/lab42/curry/currier.rb', line 6 def context @context end |
#ct_args ⇒ Object (readonly)
Returns the value of attribute ct_args.
6 7 8 |
# File 'lib/lab42/curry/currier.rb', line 6 def ct_args @ct_args end |
#ct_blk ⇒ Object (readonly)
Returns the value of attribute ct_blk.
6 7 8 |
# File 'lib/lab42/curry/currier.rb', line 6 def ct_blk @ct_blk end |
#ct_kwds ⇒ Object (readonly)
Returns the value of attribute ct_kwds.
6 7 8 |
# File 'lib/lab42/curry/currier.rb', line 6 def ct_kwds @ct_kwds end |
#mthd ⇒ Object (readonly)
Returns the value of attribute mthd.
6 7 8 |
# File 'lib/lab42/curry/currier.rb', line 6 def mthd @mthd end |
Instance Method Details
#_bind_and_call(args, kwds, blk) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# 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) ⇒ Object
28 29 30 31 32 33 34 35 |
# 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) ⇒ Object
8 9 10 11 12 13 14 15 |
# 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 |