Class: Lab42::Curry::Currier

Inherits:
Object
  • Object
show all
Defined in:
lib/lab42/curry/currier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arg_compilerObject (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

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/lab42/curry/currier.rb', line 6

def context
  @context
end

#ct_argsObject (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_blkObject (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_kwdsObject (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

#mthdObject (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