class ActiveWorker::Configuration

Constants

POLLING_INTERVAL

Public Class Methods

after_launch(method) click to toggle source
# File lib/active_worker/configuration.rb, line 134
def self.after_launch(method)
  after_launch_methods << method
end
after_launch_methods() click to toggle source
# File lib/active_worker/configuration.rb, line 138
def self.after_launch_methods
  @after_launch_methods ||= []
end
config_field(name, *args) click to toggle source
# File lib/active_worker/configuration.rb, line 121
def self.config_field(name, *args)
  field name, *args
  config_fields << name
end
config_fields() click to toggle source
# File lib/active_worker/configuration.rb, line 130
def self.config_fields
  @config_fields ||= []
end
controller_class() click to toggle source
# File lib/active_worker/configuration.rb, line 104
def self.controller_class
  "#{self.parent}::Controller".constantize
end
css_name() click to toggle source
# File lib/active_worker/configuration.rb, line 112
def self.css_name
  name.split("::").join("_")
end
display_name() click to toggle source
# File lib/active_worker/configuration.rb, line 108
def self.display_name
  name.split("::").join(" ")
end
template_field(name, *args) click to toggle source
# File lib/active_worker/configuration.rb, line 116
def self.template_field(name, *args)
  config_field(name, *args)
  template_fields << name
end
template_fields() click to toggle source
# File lib/active_worker/configuration.rb, line 126
def self.template_fields
  @template_fields ||= []
end

Public Instance Methods

collect_after_launch_configurations(configurations) click to toggle source
# File lib/active_worker/configuration.rb, line 36
def collect_after_launch_configurations(configurations)
  self.class.after_launch_methods.map { |method| send(method, configurations) }.flatten
end
completed?() click to toggle source
# File lib/active_worker/configuration.rb, line 75
def completed?
  FinishedEvent.where(configuration_id: id).count > 0
end
configurations_for_events() click to toggle source
# File lib/active_worker/configuration.rb, line 48
def configurations_for_events
  [self]
end
defined_fields() click to toggle source
# File lib/active_worker/configuration.rb, line 61
def defined_fields
  attributes.select { |k, v| self.class.config_fields.include? k.to_sym }
end
enqueue_job() click to toggle source
# File lib/active_worker/configuration.rb, line 52
def enqueue_job
  self.class.controller_class.run_remotely.execute_expanded(self.id)
  self
end
event_name() click to toggle source
# File lib/active_worker/configuration.rb, line 65
def event_name
  parts = self.class.name.split("::")
  parts.pop
  parts.join(" ")
end
expand_for_threads() click to toggle source
# File lib/active_worker/configuration.rb, line 44
def expand_for_threads
  [self]
end
expand_for_workers() click to toggle source
# File lib/active_worker/configuration.rb, line 40
def expand_for_workers
  [self]
end
finished() click to toggle source
# File lib/active_worker/configuration.rb, line 87
def finished
  FinishedEvent.create(configuration: self)
end
launch() click to toggle source
# File lib/active_worker/configuration.rb, line 29
def launch
  configurations = expand_for_workers
  configurations.each(&:enqueue_job)
  configurations += collect_after_launch_configurations(configurations)
  configurations
end
notified?() click to toggle source
# File lib/active_worker/configuration.rb, line 95
def notified?
  NotificationEvent.where(configuration_id: id).count > 0
end
notify() click to toggle source
# File lib/active_worker/configuration.rb, line 91
def notify
  NotificationEvent.create(configuration: self)
end
renderable_configurations() click to toggle source
# File lib/active_worker/configuration.rb, line 71
def renderable_configurations
  configurations.select { |c| c.renderable }
end
set_flags() click to toggle source
# File lib/active_worker/configuration.rb, line 99
def set_flags
  self.flags = parent_configuration.flags if parent_configuration
  true
end
started() click to toggle source
# File lib/active_worker/configuration.rb, line 83
def started
  StartedEvent.create(configuration: self)
end
supported_child_configurations() click to toggle source
# File lib/active_worker/configuration.rb, line 57
def supported_child_configurations
  []
end
wait_until_completed() click to toggle source
# File lib/active_worker/configuration.rb, line 79
def wait_until_completed
  sleep(POLLING_INTERVAL) until completed?
end