Method: ActiveRecord::Core#pretty_print

Defined in:
lib/active_record/core.rb

#pretty_print(pp) ⇒ Object

Takes a PP and prettily prints this record to it, allowing you to get a nice result from pp record when pp is required.



515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'lib/active_record/core.rb', line 515

def pretty_print(pp)
  return super if custom_inspect_method_defined?
  pp.object_address_group(self) do
    if defined?(@attributes) && @attributes
      column_names = self.class.column_names.select { |name| has_attribute?(name) || new_record? }
      pp.seplist(column_names, proc { pp.text "," }) do |column_name|
        column_value = read_attribute(column_name)
        pp.breakable " "
        pp.group(1) do
          pp.text column_name
          pp.text ":"
          pp.breakable
          pp.pp column_value
        end
      end
    else
      pp.breakable " "
      pp.text "not initialized"
    end
  end
end