Module: Core::Inspect
- Extended by:
- Extension, Local
- Defined in:
- lib/core/inspect.rb,
lib/core/inspect/version.rb,
lib/core/inspect/inspection.rb
Overview
- public
-
Customized inspections for any object.
Defined Under Namespace
Classes: Inspection
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
- .inspected_objects ⇒ Object
- .inspecting?(object) ⇒ Boolean
- .prevent_recursion(object) ⇒ Object
- .version ⇒ Object
Instance Method Summary collapse
-
#inspect ⇒ Object
- public
-
Inspects the object.
Class Method Details
.inspected_objects ⇒ Object
113 114 115 |
# File 'lib/core/inspect.rb', line 113 def inspected_objects localized(:__corerb_inspected_objects__) || localize(:__corerb_inspected_objects__, {}) end |
.inspecting?(object) ⇒ Boolean
109 110 111 |
# File 'lib/core/inspect.rb', line 109 def inspecting?(object) inspected_objects[object.object_id] end |
.prevent_recursion(object) ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/core/inspect.rb', line 101 def prevent_recursion(object) object_id = object.object_id inspected_objects[object_id] = true yield ensure inspected_objects.delete(object_id) end |
.version ⇒ Object
7 8 9 |
# File 'lib/core/inspect/version.rb', line 7 def self.version VERSION end |
Instance Method Details
#inspect ⇒ Object
- public
-
Inspects the object.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/core/inspect.rb', line 64 def inspect inspection = +"#<#{self.class}:0x#{__id__.to_s(16)}" if Inspect.inspecting?(self) "#{inspection} ...>" else Inspect.prevent_recursion(self) do each_inspectable do |inspectable| inspection << ", #{inspectable.name}=#{inspectable.resolve(self).inspect}" end inspection.strip << ">" end end end |