Class: Proc

Inherits:
Object show all
Defined in:
lib/core_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.to_lambda(block) ⇒ Object



193
194
195
196
197
198
199
200
201
202
# File 'lib/core_extensions.rb', line 193

def self.to_lambda(block)
  raise 'argument is not a Proc' unless block.is_a?(Proc)
  if RUBY_ENGINE && RUBY_ENGINE == "jruby"
    return lambda(&block)
  else
    obj = Object.new
    obj.define_singleton_method(:_, &block)
    return obj.method(:_).to_proc
  end
end

Instance Method Details

#to_lambdaObject



204
205
206
# File 'lib/core_extensions.rb', line 204

def to_lambda
  self.class.to_lambda(self)
end