Module: Terrestrial::InspectionString

Included in:
CollectionMutabilityProxy, LazyCollection, LazyObjectProxy, ObjectStore, RelationalStore
Defined in:
lib/terrestrial/inspection_string.rb

Instance Method Summary collapse

Instance Method Details

#inspectObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/terrestrial/inspection_string.rb', line 3

def inspect
  original_inspect_string = super
  # this is kind of a silly way of getting the object id hex string but
  # multiple Ruby versions have changed how this calculated.
  hex_object_id = /#{self.class.to_s}:0x([0-9a-f]+)/.match(original_inspect_string)[1]

  (
    ["\#<#{self.class.to_s}:0x#{hex_object_id}"] +
    inspectable_properties.map { |name|
      [
        name,
        instance_variable_get("@#{name}").inspect
      ].join("=")
    }
  ).join(" ") + ">"
end