module ExplicitReturn::MethodWrapper
Public Class Methods
busy?()
click to toggle source
# File lib/explicit-return.rb, line 49 def self.busy? @@wrapping_method end
wrap_method(context, method, type)
click to toggle source
# 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)
click to toggle source
# 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