Module: Mongoid::Inspectable

Included in:
Composable
Defined in:
lib/mongoid/inspectable.rb

Overview

Contains the bahviour around inspecting documents via inspect.

Since:

  • 4.0.0

Instance Method Summary collapse

Instance Method Details

#inspectString

Returns the class name plus its attributes. If using dynamic fields will include those as well.

Examples:

Inspect the document.

person.inspect

Returns:

  • (String)

    A nice pretty string to look at.

Since:

  • 1.0.0


18
19
20
21
22
# File 'lib/mongoid/inspectable.rb', line 18

def inspect
  inspection = []
  inspection.concat(inspect_fields).concat(inspect_dynamic_fields)
  "#<#{self.class.name} _id: #{id}, #{inspection * ', '}>"
end