Module: Gecko::Helpers::InspectionHelper

Included in:
Record::Base
Defined in:
lib/gecko/helpers/inspection_helper.rb

Overview

Helper for providing custom #inspect values to Records

Instance Method Summary collapse

Instance Method Details

#inspectString

Overrides the default inspect to just return the defined attributes

Examples:

company.inspect #=> <Gecko::Record::Company id=123 name="Gecko Inc">

Returns:

  • (String)


15
16
17
18
19
20
21
# File 'lib/gecko/helpers/inspection_helper.rb', line 15

def inspect
  inspection = self.class.attribute_set.map do |attribute|
    name = attribute.name
    "#{name}: #{attribute_for_inspect(name)}"
  end.join(', ')
  "#<#{self.class} #{inspection}>"
end