Module: Arask
- Defined in:
- lib/arask.rb,
lib/arask/setup.rb,
lib/arask/railtie.rb,
lib/arask/version.rb,
lib/arask/run_jobs.rb,
lib/arask/arask_job.rb
Defined Under Namespace
Classes: AraskJob, InstallGenerator, Railtie, RunJobs, Setup
Constant Summary collapse
- VERSION =
'1.2.2'
Class Attribute Summary collapse
-
.exception_block ⇒ Object
Returns the value of attribute exception_block.
-
.exception_email ⇒ Object
Returns the value of attribute exception_email.
-
.exception_email_from ⇒ Object
Returns the value of attribute exception_email_from.
-
.jobs_touched ⇒ Object
Returns the value of attribute jobs_touched.
Class Method Summary collapse
Class Attribute Details
.exception_block ⇒ Object
Returns the value of attribute exception_block.
8 9 10 |
# File 'lib/arask.rb', line 8 def exception_block @exception_block end |
.exception_email ⇒ Object
Returns the value of attribute exception_email.
8 9 10 |
# File 'lib/arask.rb', line 8 def exception_email @exception_email end |
.exception_email_from ⇒ Object
Returns the value of attribute exception_email_from.
8 9 10 |
# File 'lib/arask.rb', line 8 def exception_email_from @exception_email_from end |
.jobs_touched ⇒ Object
Returns the value of attribute jobs_touched.
8 9 10 |
# File 'lib/arask.rb', line 8 def jobs_touched @jobs_touched end |
Class Method Details
.queue_self ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/arask.rb', line 27 def self.queue_self begin next_job_run = AraskJob.order(execute_at: :asc).first.try(:execute_at) # At least check database for jobs every day next_job_run = 1.day.from_now if next_job_run.nil? or (next_job_run - DateTime.now)/60/60 > 24 RunJobs.set(wait_until: next_job_run).perform_later rescue end end |
.setup(force_run = false) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/arask.rb', line 10 def self.setup(force_run = false) # Make sure we only run setup if Rails is actually run as a server or testing. return unless defined?(Rails::Server) or force_run # If we don't wait and rails is setup to use another language, ActiveJob # saves what is now (usually :en) and reloads that when trying to run the # job. Renderering an I18n error of unsupported language. ActiveSupport.on_load :after_initialize, yield: true do Arask.jobs_touched = [] yield Setup begin AraskJob.all.where.not(id: Arask.jobs_touched).delete_all Arask.queue_self rescue end end end |