Class: RailsConsolePro::Commands::JobsCommand

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

Constant Summary collapse

DEFAULT_LIMIT =
20

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(options = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_console_pro/commands/jobs_command.rb', line 8

def execute(options = nil)
  unless feature_enabled?
    puts pastel.yellow("Jobs command is disabled. Enable it with: RailsConsolePro.configure { |c| c.queue_command_enabled = true }")
    return nil
  end

  unless active_job_available?
    puts pastel.red("ActiveJob is not loaded. Queue insights require ActiveJob to be available.")
    return nil
  end

  normalized_options = normalize_options(options)

  fetch_options, filter_options, action_options = split_options(normalized_options)
  action_results = perform_actions(action_options, fetch_options)
  action_results.each { |result| print_action_result(result) }

  result = fetcher.fetch(**fetch_options)
  return result unless result

  apply_filters(result, filter_options)
rescue => e
  RailsConsolePro::ErrorHandler.handle(e, context: :jobs)
end