Skip to content

Commit 15eb026

Browse files
committed
Add a note about Helper Inclusion to README
This comes from my own usage pattern in other projects.
1 parent 9f8507d commit 15eb026

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## [Unreleased]
22

3+
- Add a note about Helper Inclusion to README
34
- Add ObjectInspector::InspectorsHelper#inspect! as a short form for #inspect(scope: :all)
45

56
### 0.9.0 - 2025-3-23

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,30 @@ MyObject.new.inspect
181181
# => "<My Object(FLAG1) !!ISSUE1 | ISSUE2!! INFO :: NAME>"
182182
```
183183

184+
### Helper Inclusion
185+
186+
It may be useful to conditionally include ObjectInspector::InspectorsHelper, as well as other similar methods, via a mix-in.
187+
188+
```ruby
189+
module ObjectInspectionBehaviors
190+
extend ActiveSupport::Concern
191+
192+
included do
193+
# If you'd like to preserve the original inspect method, here is your
194+
# chance to.
195+
alias_method :__inspect__, :inspect
196+
197+
include ObjectInspector::InspectorsHelper
198+
end
199+
200+
# An example of another, similar style of method you may wish to utilize in
201+
# this mix-in.
202+
def introspect
203+
self
204+
end
205+
end
206+
```
207+
184208
## Scopes
185209

186210
Use the `scope` option to define the scope of the `inspect_*` methods. The supplied value will be wrapped by the ObjectInspector::Scope helper object.

0 commit comments

Comments
 (0)