Sha256: 703994fa1b5ff4ca9f3e50ee9f470eb67726de466cc711ee79f70a4e9706a4c4

Contents?: true

Size: 795 Bytes

Versions: 4

Compression:

Stored size: 795 Bytes

Contents

module QPush
  module Server
    # The Loader will 'require' all jobs within the users job folder.
    # The job folder is specified in the config.
    #
    class JobLoader
      # Provides a shortend caller.
      #
      def self.call
        loader = new
        loader.call
      end

      # Entrypoint to load all jobs.
      #
      def call
        flush_jobs
        load_jobs
      end

      private

      # Removes old jobs from the redis job list.
      #
      def flush_jobs
        Server.redis { |c| c.del(QPush::Base::KEY + ':jobs') }
      end

      # Requires user jobs that are specified from the config.
      #
      def load_jobs
        Dir[Dir.pwd + "#{Server.config.jobs_path}/**/*.rb"].each do |file|
          require file
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qpush-0.1.10 lib/qpush/server/loader.rb
qpush-0.1.8 lib/qpush/server/loader.rb
qpush-0.1.7 lib/qpush/server/loader.rb
qpush-0.1.6 lib/qpush/server/loader.rb