Class: Jobler::JobScheduler
- Inherits:
-
Object
- Object
- Jobler::JobScheduler
- Defined in:
- lib/jobler/job_scheduler.rb
Instance Attribute Summary collapse
-
#job ⇒ Object
readonly
Returns the value of attribute job.
Class Method Summary collapse
Instance Method Summary collapse
- #create_job ⇒ Object
-
#initialize(args) ⇒ JobScheduler
constructor
A new instance of JobScheduler.
- #perform_job_later ⇒ Object
Constructor Details
#initialize(args) ⇒ JobScheduler
Returns a new instance of JobScheduler.
11 12 13 14 15 16 |
# File 'lib/jobler/job_scheduler.rb', line 11 def initialize(args) @controller = args[:controller] @jobler_type = args.fetch(:jobler_type) @job_args = args[:job_args] @locale = args[:locale] end |
Instance Attribute Details
#job ⇒ Object (readonly)
Returns the value of attribute job.
2 3 4 |
# File 'lib/jobler/job_scheduler.rb', line 2 def job @job end |
Class Method Details
.create!(args) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/jobler/job_scheduler.rb', line 4 def self.create!(args) scheduler = Jobler::JobScheduler.new(args) scheduler.create_job scheduler.perform_job_later scheduler end |
Instance Method Details
#create_job ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jobler/job_scheduler.rb', line 18 def create_job @job = Jobler::Job.new( jobler_type: @jobler_type, locale: @locale.presence || I18n.locale, parameters: YAML.dump(@job_args) ) if @controller @job.assign_attributes( host: @controller.request.host, port: @controller.request.port, protocol: @controller.request.protocol ) end @job.save! end |