Module: Flex::ActiveModel::Inspection

Defined in:
lib/flex/active_model/inspection.rb

Instance Method Summary collapse

Instance Method Details

#inspectObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/flex/active_model/inspection.rb', line 5

def inspect
  descriptions   = [%(_id: #{@_id.inspect}), %(_version: #{@_version})]
  all_attributes = if respond_to?(:raw_document)
                     reader_keys = raw_document.send(:readers).keys.map(&:to_s)
                     # we send() the readers, so they will reflect an eventual overriding
                     Hash[ reader_keys.map{ |k| [k, send(k)] } ].merge(attributes)
                   else
                     attributes
                   end
  descriptions << all_attributes.sort.map { |key, value| "#{key}: #{value.inspect}" }
  separator = " " unless descriptions.empty?
  "#<#{self.class.name}#{separator}#{descriptions.join(", ")}>"
end