Module: ExplicitReturn::MethodWrapper
- Defined in:
- lib/explicit-return.rb
Constant Summary collapse
- @@wrapping_method =
false
Class Method Summary collapse
Class Method Details
.busy? ⇒ Boolean
49 50 51 |
# File 'lib/explicit-return.rb', line 49 def self.busy? @@wrapping_method end |
.wrap_method(context, method, type) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/explicit-return.rb', line 53 def self.wrap_method(context, method, type) proc = wrap_proc(method.to_proc) @@wrapping_method = true case type when :instance context.send(:define_method, method.name, &proc) when :singleton context.send(:define_singleton_method, method.name, &proc) end @@wrapping_method = false end |
.wrap_proc(proc) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/explicit-return.rb', line 65 def self.wrap_proc(proc) proc_wrapper = Proc.new{|*args, &block| ret = proc.call(*args, &block) ret.value if ret.is_a?(ExplicitReturn::ExplicitResult) } end |