Class: RailsConsolePro::Printers::CollectionPrinter

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

Overview

Printer for Array of ActiveRecord objects

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
# File 'lib/rails_console_pro/printers/collection_printer.rb', line 7

def print
  return print_empty_collection if value.empty?
  return print_non_active_record_array unless active_record_array?

  # Use pagination for large collections
  total_count = value.size
  record_printer = proc { |record| ActiveRecordPrinter.new(output, record, pry_instance).print }
  
  Paginator.new(output, value, total_count, config, record_printer).paginate
end