Class: Accidentally::MethodInvoker
- Defined in:
- lib/accidentally/method_invoker.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(v) ⇒ MethodInvoker
constructor
A new instance of MethodInvoker.
- #invoke(meth, args, &blk) ⇒ Object
Constructor Details
#initialize(v) ⇒ MethodInvoker
Returns a new instance of MethodInvoker.
11 12 13 |
# File 'lib/accidentally/method_invoker.rb', line 11 def initialize v @v = v end |
Class Method Details
.invoke(v, meth, args, &blk) ⇒ Object
7 8 9 |
# File 'lib/accidentally/method_invoker.rb', line 7 def self.invoke v, meth, args, &blk self.new(v).invoke(meth, args, &blk) end |
Instance Method Details
#invoke(meth, args, &blk) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/accidentally/method_invoker.rb', line 15 def invoke meth, args, &blk # TODO This look bad. Too many places where invocation results are getting built # and failure happening. v, warns = yield_and_collect_stderr { value, fail = either { do_send(meth, args, &blk) } if should_do_block_execute(value, fail) then r, fail = either { invoke_and_infer_block(meth, args) } r || InvocationResult.new(fail) else InvocationResult.new(value) end } # TODO handle the warns v end |