Module: Is::Inspectable
- Extended by:
- Extension, Localized
- Defined in:
- lib/is/inspectable.rb
Overview
- public
-
Customized inspections for any object.
Class Method Summary collapse
Instance Method Summary collapse
-
#inspect ⇒ Object
- public
-
Inspects the object.
Class Method Details
.inspected_objects ⇒ Object
112 113 114 |
# File 'lib/is/inspectable.rb', line 112 def inspected_objects localized(:__corerb_inspected_objects__) || localize(:__corerb_inspected_objects__, {}) end |
.inspecting?(object) ⇒ Boolean
108 109 110 |
# File 'lib/is/inspectable.rb', line 108 def inspecting?(object) inspected_objects[object.object_id] end |
.prevent_recursion(object) ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/is/inspectable.rb', line 100 def prevent_recursion(object) object_id = object.object_id inspected_objects[object_id] = true yield ensure inspected_objects.delete(object_id) end |
Instance Method Details
#inspect ⇒ Object
- public
-
Inspects the object.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/is/inspectable.rb', line 63 def inspect inspection = +"#<#{self.class}:0x#{__id__.to_s(16)}" if Inspectable.inspecting?(self) "#{inspection} ...>" else Inspectable.prevent_recursion(self) do each_inspectable do |inspectable| inspection << ", #{inspectable.name}=#{inspectable.resolve(self).inspect}" end inspection.strip << ">" end end end |