Class: Object

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

Overview

Provides several backports of Ruby 1.9 features for Ruby implementations not supporting them

Author:

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) respond_to?(name, include_private = false)

Returns whether this object responds to the given method

Parameters:

  • name (Symbol)

    The name of the method that should be called

  • include_private (Boolean) (defaults to: false)

    If true includes private method in the lookup

Returns:

  • (Boolean)

    true if the method is implemented or can be called dynamically

See Also:



35
36
37
# File 'lib/core_ext/object.rb', line 35

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

- (Boolean) respond_to_missing?(name, include_private = false)

Returns whether the object can respond to a method

Parameters:

  • name (Symbol)

    The name of the method that should be called

  • include_private (Boolean) (defaults to: false)

    If true includes private method in the lookup

Returns:

  • (Boolean)

    true if this object responds to this method via via method_missing

See Also:



48
49
50
# File 'lib/core_ext/object.rb', line 48

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

- (Class) singleton_class

Returns the singleton class (also known as eigenclass) of this object

Returns:

  • (Class)

    The singleton class of this object



17
18
19
20
21
# File 'lib/core_ext/object.rb', line 17

def singleton_class
  class << self
     self
  end
end