Module: Ribbon::CoreExtensions::BasicObject

Defined in:
lib/ribbon/core_extensions/basic_object.rb

Overview

Some useful methods.

Author:

  • Matheus Afonso Martins Moreira

Since:

  • 0.6.0

Instance Method Summary collapse

Instance Method Details

#__yield_or_eval__ {|object| ... } ⇒ Object?

Evaluates the block using instance_eval if it takes no arguments; yields self to it otherwise.

Yield Parameters:

  • object (self)

    this instance

Returns:

  • (Object, nil)

    the result of the block or nil if not given one

Since:

  • 0.6.0



15
16
17
# File 'lib/ribbon/core_extensions/basic_object.rb', line 15

def __yield_or_eval__(&block)
  if block.arity.zero? then instance_eval &block else block.call self end if block
end