Class: Hanami::Utils::BasicObject

Inherits:
BasicObject
Defined in:
lib/hanami/utils/basic_object.rb

Overview

BasicObject

Since:

  • 0.3.5

Direct Known Subclasses

Interactor::Result

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object, Module

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Lookups constants at the top-level namespace, if they are missing in the current context.

Parameters:

  • name (Symbol)

    the constant name

Returns:

  • (Object, Module)

    the constant

Raises:

  • (NameError)

    if the constant cannot be found

See Also:

Since:

  • 1.3.4


22
23
24
# File 'lib/hanami/utils/basic_object.rb', line 22

def self.const_missing(name)
  ::Object.const_get(name)
end

Instance Method Details

#classObject

Returns the class for debugging purposes.


31
32
33
# File 'lib/hanami/utils/basic_object.rb', line 31

def class
  (class << self; self; end).superclass
end

#inspectString

Bare minimum inspect for debugging purposes.

rubocop:disable Style/FormatStringToken

Returns:

  • (String)

    the inspect string

See Also:

Since:

  • 0.3.5


44
45
46
# File 'lib/hanami/utils/basic_object.rb', line 44

def inspect
  "#<#{self.class}:#{'0x0000%x' % (__id__ << 1)}#{__inspect}>"
end

#instance_of?Object

Since:

  • 0.3.5


62
# File 'lib/hanami/utils/basic_object.rb', line 62

define_method :instance_of?, ::Object.instance_method(:instance_of?)

#is_a?Object

Since:

  • 0.3.5


77
# File 'lib/hanami/utils/basic_object.rb', line 77

define_method :is_a?, ::Object.instance_method(:is_a?)

#kind_of?Object

Since:

  • 0.3.5


92
# File 'lib/hanami/utils/basic_object.rb', line 92

define_method :kind_of?, ::Object.instance_method(:kind_of?)

#object_idFixnum

Alias for __id__

Returns:

  • (Fixnum)

    the object id

See Also:

Since:

  • 0.9.0


101
102
103
# File 'lib/hanami/utils/basic_object.rb', line 101

def object_id
  __id__
end

#pretty_print(printer) ⇒ String

Interface for pp

Parameters:

  • printer (PP)

    the Pretty Printable printer

Returns:

  • (String)

    the pretty-printable inspection of the object

See Also:

Since:

  • 0.9.0


113
114
115
# File 'lib/hanami/utils/basic_object.rb', line 113

def pretty_print(printer)
  printer.text(inspect)
end

#respond_to?(method_name, include_all = false) ⇒ TrueClass, FalseClass

Returns true if responds to the given method.

Returns:

  • (TrueClass, FalseClass)

    the result of the check

See Also:

Since:

  • 0.3.5


124
125
126
# File 'lib/hanami/utils/basic_object.rb', line 124

def respond_to?(method_name, include_all = false)
  respond_to_missing?(method_name, include_all)
end