Class: RSpec::Support::ObjectFormatter::UninspectableObjectInspector Private

Inherits:
BaseInspector
  • Object
show all
Defined in:
lib/rspec/support/object_formatter.rb

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

Constant Summary collapse

OBJECT_ID_FORMAT =

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

'%#016x'

Instance Attribute Summary

Attributes inherited from BaseInspector

#formatter, #object

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseInspector

#pretty_print

Class Method Details

.can_inspect?(object) ⇒ Boolean

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.

Returns:

  • (Boolean)


190
191
192
193
194
195
# File 'lib/rspec/support/object_formatter.rb', line 190

def self.can_inspect?(object)
  object.inspect
  false
rescue NoMethodError
  true
end

Instance Method Details

#inspectObject

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.



197
198
199
# File 'lib/rspec/support/object_formatter.rb', line 197

def inspect
  "#<#{klass}:#{native_object_id}>"
end

#klassObject

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.



201
202
203
204
# File 'lib/rspec/support/object_formatter.rb', line 201

def klass
  singleton_class = class << object; self; end
  singleton_class.ancestors.find { |ancestor| !ancestor.equal?(singleton_class) }
end

#native_object_idObject

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.

stackoverflow.com/a/2818916



207
208
209
210
211
212
# File 'lib/rspec/support/object_formatter.rb', line 207

def native_object_id
  OBJECT_ID_FORMAT % (object.__id__ << 1)
rescue NoMethodError
  # In Ruby 1.9.2, BasicObject responds to none of #__id__, #object_id, #id...
  '-'
end