module Dronejob::Loader

Public Class Methods

identifier_for(worker) click to toggle source
# File lib/dronejob/loader.rb, line 18
def self.identifier_for(worker)
  self.workers.key(worker.class)
end
load() click to toggle source
# File lib/dronejob/loader.rb, line 5
def self.load
  require "active_support/all"
  workers = {}
  Dir["#{Dronejob::Base.jobs_path}/*.rb"].each do |file|
    require "./#{file}"
    identifier = File.basename(file).gsub(/\.rb$/, "")
    klassname = identifier.camelcase
    klass = klassname.constantize
    workers[identifier] = klass
  end
  workers
end
workers(type = "base") click to toggle source
# File lib/dronejob/loader.rb, line 22
def self.workers(type = "base")
  type = type.to_s
  @@workers ||= load
  @@workers.select { |key, worker| worker::DRONEJOB_TYPE == type }
end