class Relevium::BackgroundService
Attributes
options[R]
worker_class[R]
Public Class Methods
new(options, worker_class)
click to toggle source
# File lib/relevium/background_service.rb, line 9 def initialize(options, worker_class) @options = options @worker_class = worker_class end
Private Class Methods
worker_attributes(*attributes)
click to toggle source
# File lib/relevium/background_service.rb, line 26 def self.worker_attributes(*attributes) @worker_attributes_array = attributes end
worker_attributes_array()
click to toggle source
# File lib/relevium/background_service.rb, line 30 def self.worker_attributes_array @worker_attributes_array ||= [] end
Public Instance Methods
call()
click to toggle source
# File lib/relevium/background_service.rb, line 14 def call return broadcast(:fail) unless valid? background? ? setup_worker : perform end
Private Instance Methods
background?()
click to toggle source
# File lib/relevium/background_service.rb, line 48 def background? !options[:background].nil? && options[:background] end
delay()
click to toggle source
# File lib/relevium/background_service.rb, line 44 def delay options[:perform_in] || 5.minutes end
fetch_worker_attributes()
click to toggle source
# File lib/relevium/background_service.rb, line 34 def fetch_worker_attributes self.class.worker_attributes_array.map do |worker_attribute| instance_variable_get("@#{worker_attribute}") end end
perform()
click to toggle source
# File lib/relevium/background_service.rb, line 22 def perform NoMethodError end
setup_worker()
click to toggle source
# File lib/relevium/background_service.rb, line 40 def setup_worker worker_class.perform_in(delay, self.class, *fetch_worker_attributes) end
valid?()
click to toggle source
# File lib/relevium/background_service.rb, line 52 def valid? true end