Module: ObjectInspector::InspectBehaviors
- Defined in:
- lib/object_inspector/inspect_behaviors.rb
Overview
ObjectInspector::InspectBehaviors can be included into any object to override
the default #inspect method for that object to instead call
ObjectInspector::Inspector.inspect.
Instance Method Summary collapse
-
#inspect ⇒ String
Calls ObjectInspector::Inspector.inspect on
self, passing through any keyword arguments. -
#inspect! ⇒ String
Like #inspect but: - Ignores the enabled/disabled state of ObjectInspector - Forces scope to
:all.
Instance Method Details
#inspect ⇒ String
Calls ObjectInspector::Inspector.inspect on self, passing through any
keyword arguments.
If building the gem inspect String raises a StandardError, records the
error via ObjectInspector.record_error and falls back to the ancestor
#inspect via super (Object / ActiveRecord / etc.).
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/object_inspector/inspect_behaviors.rb', line 17 def inspect(**) return super() if ObjectInspector.configuration.disabled? ObjectInspector::Inspector.inspect(self, **).tap { ObjectInspector.clear_error } rescue => ex ObjectInspector.record_error(ex, object: self) super() end |
#inspect! ⇒ String
Like #inspect but:
- Ignores the enabled/disabled state of ObjectInspector
- Forces scope to
:all
This (the bang (!) version) is considered the "more dangerous" version of
#inspect since the :all scope may result in additional queries or extra
processing--depending on how the inspect hooks are setup.
On StandardError, records the error and falls back to #inspect (which
then falls back to the original ancestor #inspect if needed).
40 41 42 43 44 45 46 47 48 |
# File 'lib/object_inspector/inspect_behaviors.rb', line 40 def inspect!(**) ObjectInspector::Inspector.inspect(self, **, scope: :all).tap { ObjectInspector.clear_error } rescue => ex ObjectInspector.record_error(ex, object: self) inspect end |