Class: SidekiqAdhocJob::Web::JobPresenter
- Inherits:
-
Object
- Object
- SidekiqAdhocJob::Web::JobPresenter
- Includes:
- Sidekiq::WebHelpers
- Defined in:
- lib/sidekiq_adhoc_job/web/job_presenter.rb
Instance Attribute Summary collapse
-
#confirm_prompt_message ⇒ Object
readonly
Returns the value of attribute confirm_prompt_message.
-
#has_rest_args ⇒ Object
readonly
Returns the value of attribute has_rest_args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#optional_args ⇒ Object
readonly
Returns the value of attribute optional_args.
-
#optional_kw_args ⇒ Object
readonly
Returns the value of attribute optional_kw_args.
-
#path_name ⇒ Object
readonly
Returns the value of attribute path_name.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#require_confirm ⇒ Object
readonly
Returns the value of attribute require_confirm.
-
#required_args ⇒ Object
readonly
Returns the value of attribute required_args.
-
#required_kw_args ⇒ Object
readonly
Returns the value of attribute required_kw_args.
Class Method Summary collapse
-
.build_collection ⇒ Array<JobPresenter>
Builds the presenter instances for the schedule hash.
- .convert_klass_name_to_presenter(path_name, klass_name) ⇒ Object
- .find(path_name) ⇒ Object
Instance Method Summary collapse
-
#initialize(name, path_name, queue, args, require_confirm) ⇒ JobPresenter
constructor
args: { req: [], opt: [] }.
- #no_arguments? ⇒ Boolean
Constructor Details
#initialize(name, path_name, queue, args, require_confirm) ⇒ JobPresenter
args: { req: [], opt: [] }
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 21 def initialize(name, path_name, queue, args, require_confirm) @name = name @path_name = path_name @queue = queue @required_args = args[:req] || [] @optional_args = args[:opt] || [] @required_kw_args = args[:keyreq] || [] @optional_kw_args = args[:key] || [] @has_rest_args = !!args[:rest] @require_confirm = require_confirm = SidekiqAdhocJob.config. end |
Instance Attribute Details
#confirm_prompt_message ⇒ Object (readonly)
Returns the value of attribute confirm_prompt_message.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def end |
#has_rest_args ⇒ Object (readonly)
Returns the value of attribute has_rest_args.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def has_rest_args @has_rest_args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def name @name end |
#optional_args ⇒ Object (readonly)
Returns the value of attribute optional_args.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def optional_args @optional_args end |
#optional_kw_args ⇒ Object (readonly)
Returns the value of attribute optional_kw_args.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def optional_kw_args @optional_kw_args end |
#path_name ⇒ Object (readonly)
Returns the value of attribute path_name.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def path_name @path_name end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def queue @queue end |
#require_confirm ⇒ Object (readonly)
Returns the value of attribute require_confirm.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def require_confirm @require_confirm end |
#required_args ⇒ Object (readonly)
Returns the value of attribute required_args.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def required_args @required_args end |
#required_kw_args ⇒ Object (readonly)
Returns the value of attribute required_kw_args.
7 8 9 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 7 def required_kw_args @required_kw_args end |
Class Method Details
.build_collection ⇒ Array<JobPresenter>
Builds the presenter instances for the schedule hash
38 39 40 41 42 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 38 def self.build_collection WorkerClassesLoader.worker_klasses.map do |path_name, worker_klass| convert_klass_name_to_presenter(path_name, worker_klass) end end |
.convert_klass_name_to_presenter(path_name, klass_name) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 52 def self.convert_klass_name_to_presenter(path_name, klass_name) queue = SidekiqAdhocJob.config.strategy.get_queue_name(klass_name) class_inspector = SidekiqAdhocJob::Utils::ClassInspector.new(klass_name) args = class_inspector.parameters(:perform) require_confirm = SidekiqAdhocJob.config.require_confirmation?(klass_name.to_s) new(klass_name, path_name, queue, args, require_confirm) end |
.find(path_name) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 44 def self.find(path_name) klass_name = WorkerClassesLoader.find_worker_klass(path_name) return unless klass_name convert_klass_name_to_presenter(path_name, klass_name) end |
Instance Method Details
#no_arguments? ⇒ Boolean
60 61 62 |
# File 'lib/sidekiq_adhoc_job/web/job_presenter.rb', line 60 def no_arguments? required_args.empty? && optional_args.empty? && required_kw_args.empty? && optional_kw_args.empty? && !has_rest_args end |