Module: Monkey::Object::InstanceYield

Defined in:
lib/monkey/object/instance_yield.rb

Overview

Adds the private method instance_eval which is like instance_eval and yield depending on whether a block takes an argument or not.

class Foo

  def foo
    42
  end

  def bar(&block)
    instance_yield block
  end

end

conf = Foo.new
conf.bar { foo }
conf.bar { |c| c.foo }