Sha256: 778c2b21522cf24b4234ad149d4659ba5b1cc2fcf7e152ecc94add5ea7eab4c3

Contents?: true

Size: 709 Bytes

Versions: 3

Compression:

Stored size: 709 Bytes

Contents

module Cellect
  module Server
    class Loader
      include Celluloid

      attr_reader :workflow

      def initialize(workflow)
        @workflow = workflow
      end

      def load_data
        run_load!(workflow.subjects)
        mark_workflow_as_loaded
      end

      def reload_data(set)
        run_load!(set)
        workflow.subjects = set
        mark_workflow_as_loaded
      end

      private

      def mark_workflow_as_loaded
        workflow.set_reload_at_time
        workflow.state = :ready
      end

      def run_load!(set)
        Cellect::Server.adapter.load_data_for(workflow.name) do |hash|
          set.add hash['id'], hash['priority']
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cellect-server-3.0.2 lib/cellect/server/loader.rb
cellect-server-3.0.1 lib/cellect/server/loader.rb
cellect-server-3.0.0 lib/cellect/server/loader.rb