Module: Lab42::Console::Tools
- Extended by:
- Tools
- Included in:
- Tools
- Defined in:
- lib/lab42/console/tools.rb,
lib/lab42/console/tools/forward_to_new_instance.rb
Defined Under Namespace
Modules: ForwardToNewInstance
Instance Method Summary
collapse
Instance Method Details
#make_fn(fn_ary, blk) ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/lab42/console/tools.rb', line 6
def make_fn fn_ary, blk
return ->(x){x} if fn_ary.empty? && blk.nil?
return blk if fn_ary.empty?
make_fn_from_ary( *fn_ary ).tap do | argfn |
return ->(x){ blk.(argfn.(x)) } if blk
end
end
|
#make_fn_from_ary(desc, *args) ⇒ Object
17
18
19
20
21
|
# File 'lib/lab42/console/tools.rb', line 17
def make_fn_from_ary desc, *args
-> (rcv, *a) {
rcv.send(desc, *(args + a))
}
end
|
#make_partial(mthd, args, blk) ⇒ Object
24
25
26
27
28
|
# File 'lib/lab42/console/tools.rb', line 24
def make_partial mthd, args, blk
make_partial_from(mthd, args).tap do | partial |
return ->(*x){ blk.(partial.(*x)) } if blk
end
end
|
#make_partial_from(mthd, args) ⇒ Object
30
31
32
33
34
|
# File 'lib/lab42/console/tools.rb', line 30
def make_partial_from mthd, args
-> (*a) {
mthd.( *(args + a) )
}
end
|