Class: DashingContrib::RunnableJob::Context
- Inherits:
-
Object
- Object
- DashingContrib::RunnableJob::Context
- Defined in:
- lib/dashing-contrib/runnable_job.rb
Instance Method Summary collapse
-
#initialize(interval, rufus_opts, event_name, user_options, this_module) ⇒ Context
constructor
A new instance of Context.
- #schedule! ⇒ Object
Constructor Details
#initialize(interval, rufus_opts, event_name, user_options, this_module) ⇒ Context
Returns a new instance of Context.
14 15 16 17 18 19 20 |
# File 'lib/dashing-contrib/runnable_job.rb', line 14 def initialize(interval, rufus_opts, event_name, , this_module) @interval = interval @rufus_opts = rufus_opts @event_name = event_name @user_options = @this_module = this_module end |
Instance Method Details
#schedule! ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dashing-contrib/runnable_job.rb', line 22 def schedule! _scheduler.every @interval, @rufus_opts do current_metrics = @this_module.metrics(@user_options) current_state = @this_module.validate_state(current_metrics, @user_options) # including title and state additional_info = { state: current_state } additional_info[:title] = @user_options[:title] if @user_options[:title] send_event(@event_name, current_metrics.merge(additional_info)) end end |