Class: Object

Inherits:
BasicObject
Defined in:
lib/core_ext/object.rb

Overview

Extends Ruby's own Object class with method #respond_to_missing? for Ruby < 1.9.2

Author:

  • Sebastian Staudt

Since:

  • 0.4.0

Instance Method Summary collapse

Instance Method Details

#respond_to?(symbol, include_private = false) ⇒ Boolean

Returns true if obj responds to the given method. Private methods are included in the search only if the optional second parameter evaluates to true.

If the method is not implemented, as Process.fork on Windows, File.lchmod on GNU/Linux, etc., false is returned.

If the method is not defined, respond_to_missing? method is called and the result is returned.

Returns:

  • (Boolean)

See Also:

Since:

  • 0.4.0



26
27
28
# File 'lib/core_ext/object.rb', line 26

def respond_to?(symbol, include_private = false)
  super || respond_to_missing?(symbol, include_private)
end

#respond_to_missing?(symbol, include_private = false) ⇒ Boolean

Hook method to return whether the obj can respond to id method or not.

Parameters:

  • symbol (Symbol) —

    The id of the method to check

Returns:

  • (Boolean) —

    true if this object responds to this method via via method_missing

See Also:

Since:

  • 0.4.0



38
39
40
# File 'lib/core_ext/object.rb', line 38

def respond_to_missing?(symbol, include_private = false)
  false
end