123456789_123456789_123456789_123456789_123456789_

Class: Test::Unit::Assertions::AssertionMessage::Inspector

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Comparable
Inherits: Object
Defined in: lib/test/unit/assertions.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(object, inspected_objects = {}) ⇒ Inspector

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1834

def initialize(object, inspected_objects={})
  @inspected_objects = inspected_objects
  @object = object
  @inspected_objects[@object.object_id] = self
  @inspect_target = inspect_target
end

Class Method Details

.cached_new(object, inspected_objects)

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1814

def cached_new(object, inspected_objects)
  inspected_objects[object.object_id] ||=
    new(object, inspected_objects)
end

.inspector_classes

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1820

def inspector_classes
  @@inspector_classes
end

.register_inspector_class(inspector_class)

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1824

def register_inspector_class(inspector_class)
  @@inspector_classes << inspector_class
end

.unregister_inspector_class(inspector_class)

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1828

def unregister_inspector_class(inspector_class)
  @@inspector_classes.delete(inspector_class)
end

Instance Attribute Details

#object (readonly)

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1833

attr_reader :object

Instance Method Details

#<=>(other)

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1854

def <=>(other)
  if other.is_a?(self.class)
    @object <=> other.object
  else
    @object <=> other
  end
end

#inspect

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1842

def inspect
  @inspect_target.inspect
end

#inspect_target (private)

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1863

def inspect_target
  self.class.inspector_classes.each do |inspector_class|
    if inspector_class.target?(@object)
      return inspector_class.new(@object, @inspected_objects)
    end
  end
  @object
end

#native_inspect

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1841

alias_method :native_inspect, :inspect

#pretty_print(q)

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1846

def pretty_print(q)
  @inspect_target.pretty_print(q)
end

#pretty_print_cycle(q)

[ GitHub ]

  
# File 'lib/test/unit/assertions.rb', line 1850

def pretty_print_cycle(q)
  @inspect_target.pretty_print_cycle(q)
end