Class: JobPresenter
- Inherits:
-
Object
- Object
- JobPresenter
- Defined in:
- lib/sidekiq-web-workers/job_presenter.rb
Instance Attribute Summary collapse
-
#worker_name ⇒ Object
readonly
Returns the value of attribute worker_name.
Instance Method Summary collapse
- #description ⇒ Object
- #empty? ⇒ Boolean
- #escaped_name ⇒ Object
- #include?(text) ⇒ Boolean
-
#initialize(job_name) ⇒ JobPresenter
constructor
A new instance of JobPresenter.
- #job_constantized ⇒ Object
- #method_arguments ⇒ Object
Constructor Details
#initialize(job_name) ⇒ JobPresenter
Returns a new instance of JobPresenter.
4 5 6 |
# File 'lib/sidekiq-web-workers/job_presenter.rb', line 4 def initialize(job_name) @worker_name = job_name end |
Instance Attribute Details
#worker_name ⇒ Object (readonly)
Returns the value of attribute worker_name.
2 3 4 |
# File 'lib/sidekiq-web-workers/job_presenter.rb', line 2 def worker_name @worker_name end |
Instance Method Details
#description ⇒ Object
8 9 10 |
# File 'lib/sidekiq-web-workers/job_presenter.rb', line 8 def description job_constantized.respond_to?(:description) ? job_constantized.description : "" end |
#empty? ⇒ Boolean
27 28 29 |
# File 'lib/sidekiq-web-workers/job_presenter.rb', line 27 def empty? job_constantized.blank? end |
#escaped_name ⇒ Object
31 32 33 |
# File 'lib/sidekiq-web-workers/job_presenter.rb', line 31 def escaped_name CGI.escape worker_name end |
#include?(text) ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/sidekiq-web-workers/job_presenter.rb', line 35 def include?(text) return false unless job_constantized downcased_text = text.downcase worker_name.downcase.include?(downcased_text) || description.downcase.include?(downcased_text) end |
#job_constantized ⇒ Object
21 22 23 24 25 |
# File 'lib/sidekiq-web-workers/job_presenter.rb', line 21 def job_constantized @worker_name.constantize rescue nil end |
#method_arguments ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/sidekiq-web-workers/job_presenter.rb', line 12 def method_arguments return [] unless job_constantized job_constantized.new.method(:perform).parameters #[[:opt, :param_name], [:req, :param_name]] empty if no params # for named parameters this can be [[:key, :param_name], [:keyreq, :param_name]] # key means optional keyreq means required but sidekiq does not s # sidekiq doesn't support named args tho https://github.com/mperham/sidekiq/issues/2372 end |