Module: Redstruct::Utils::Inspectable

Included in:
ConnectionProxy, Factory, Factory::Object
Defined in:
lib/redstruct/utils/inspectable.rb

Overview

Adds helper methods for calling #inspect on a custom object

Instance Method Summary collapse

Instance Method Details

#inspectString Also known as: to_s

Generates a human readable list of attributes when inspecting a custom object

Returns:



9
10
11
12
13
14
15
# File 'lib/redstruct/utils/inspectable.rb', line 9

def inspect
  attributes = inspectable_attributes.map do |key, value|
    "#{key}: <#{value.inspect}>"
  end

  return "#{self.class.name}: #{attributes.join(', ')}"
end

#inspectable_attributesHash<String, #inspect>

To be overloaded by the including class

Returns:



20
21
22
# File 'lib/redstruct/utils/inspectable.rb', line 20

def inspectable_attributes
  {}
end