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 this object to it otherwise.

Yield Parameters:

  • object (self)

    this object

Returns:

  • (::Object, nil)

    the result of the block or nil if not given one

Since:

  • 0.6.0



15
16
17
18
19
20
21
# File 'lib/ribbon/core_extensions/basic_object.rb', line 15

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