Class: SuperSpreader::SchedulerConfig

Inherits:
RedisModel
  • Object
show all
Defined in:
lib/super_spreader/scheduler_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RedisModel

#default_values, #delete, #initialize, #persisted?, #save

Constructor Details

This class inherits a constructor from SuperSpreader::RedisModel

Instance Attribute Details

#schedule=(value) ⇒ Object

Sets the attribute schedule

Parameters:

  • value

    the value to set the attribute schedule to.



46
47
48
# File 'lib/super_spreader/scheduler_config.rb', line 46

def schedule=(value)
  @schedule = value
end

Instance Method Details

#job_classObject



48
49
50
# File 'lib/super_spreader/scheduler_config.rb', line 48

def job_class
  job_class_name.constantize
end

#per_secondObject



64
65
66
# File 'lib/super_spreader/scheduler_config.rb', line 64

def per_second
  schedule.on_peak? ? per_second_on_peak : per_second_off_peak
end

#spread_optionsObject



56
57
58
59
60
61
62
# File 'lib/super_spreader/scheduler_config.rb', line 56

def spread_options
  {
    batch_size: batch_size,
    duration: duration,
    per_second: per_second
  }
end

#super_spreader_configObject



52
53
54
# File 'lib/super_spreader/scheduler_config.rb', line 52

def super_spreader_config
  [job_class, job_class.super_spreader_model_class]
end