Class: RailsConsolePro::Printers::RelationPrinter
- Inherits:
-
BasePrinter
- Object
- BasePrinter
- RailsConsolePro::Printers::RelationPrinter
- Defined in:
- lib/rails_console_pro/printers/relation_printer.rb
Overview
Printer for ActiveRecord::Relation instances
Instance Attribute Summary
Attributes inherited from BasePrinter
#output, #pry_instance, #value
Instance Method Summary collapse
Methods inherited from BasePrinter
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
#print ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rails_console_pro/printers/relation_printer.rb', line 7 def print model_name = value.klass.name # Use count for efficiency (doesn't load all records) total_count = value.count if total_count.zero? output.puts color(config.get_color(:warning), "Empty #{model_name} collection") return end # Use pagination with lazy loading - don't convert to array! record_printer = proc { |record| ActiveRecordPrinter.new(output, record, pry_instance).print } Paginator.new(output, value, total_count, config, record_printer).paginate end |