Class: RailsConsolePro::Commands::StatsCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/rails_console_pro/commands/stats_command.rb

Instance Method Summary collapse

Methods included from RailsConsolePro::ColorHelper

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

Dynamic Method Handling

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

Instance Method Details

#execute(model_class) ⇒ Object



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

def execute(model_class)
  return nil if model_class.nil?
  
  error_message = ModelValidator.validate_for_stats(model_class)
  if error_message
    puts pastel.red("Error: #{error_message}")
    return nil
  end

  execute_stats(model_class)
rescue => e
  RailsConsolePro::ErrorHandler.handle(e, context: :stats)
end