class DashingContrib::RunnableJob::Context

Public Class Methods

new(interval, rufus_opts, event_name, user_options, this_module) click to toggle source
# File lib/dashing-contrib/runnable_job.rb, line 14
def initialize(interval, rufus_opts, event_name, user_options, this_module)
  @interval = interval
  @rufus_opts = rufus_opts
  @event_name = event_name
  @user_options = user_options
  @this_module = this_module
end

Public Instance Methods

schedule!() click to toggle source
# 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

Private Instance Methods

_scheduler() click to toggle source
# File lib/dashing-contrib/runnable_job.rb, line 34
def _scheduler
  SCHEDULER
end