Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/core_ext/object.rb
Overview
Reopen the core Object class to add #identify to all objects.
Instance Method Summary collapse
-
#identify ⇒ Object
Data.define(:a, :b, :c)[1, “2”, :“3”].identify(:a, :b, :c, class: “Data”) # => “Data[a:1, b:"2", c::"3"]”.
Instance Method Details
#identify ⇒ Object
Data.define(:a, :b, :c)[1, “2”, :“3”].identify(:a, :b, :c, class: “Data”)
# => "Data[a:1, b:\"2\", c::\"3\"]"
1.identify(:to_s) # => "Integer[to_s:\"1\"]"
nil.identify # => "[no objects]"
%w(1 2).identify(:to_i, :to_f)
# => "String[to_i:1, to_f:1.0], String[to_i:2, to_f:2.0]"
(1..10).to_a.identify(:to_f, limit: 2)
# => "Integer[to_f:1.0], Integer[to_f:2.0], ... (8 more)"
37 38 39 |
# File 'lib/core_ext/object.rb', line 37 def identify(...) ObjectIdentifier.(self, ...) end |