Class: RailsConsolePro::Printers::ActiveRecordPrinter

Inherits:
BasePrinter
  • Object
show all
Defined in:
lib/rails_console_pro/printers/active_record_printer.rb

Overview

Printer for ActiveRecord::Base instances

Instance Attribute Summary

Attributes inherited from BasePrinter

#output, #pry_instance, #value

Instance Method Summary collapse

Methods inherited from BasePrinter

#initialize

Methods included from ColorHelper

#bold_color, #color, #method_missing, #pastel, #respond_to_missing?

Constructor Details

This class inherits a constructor from RailsConsolePro::BasePrinter

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RailsConsolePro::ColorHelper

Instance Method Details



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rails_console_pro/printers/active_record_printer.rb', line 7

def print
  class_name = value.class.name
  id = value.id || "new"
  header("#{class_name} ##{id}", 50)
  
  # Use each_pair for better performance than each
  value.attributes.each_pair do |key, val|
    print_attribute(key, val)
  end
  
  footer(50)
end