Sha256: 96931fc8f0879fb08f2f2e8f860af9ab960e81cf3ea181d3072d1e324ce0ca31

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

require "alephant/logger"
require "alephant/broker/component"

module Alephant
  module Broker
    module Request
      class Batch
        include Logger

        attr_reader :batch_id, :components, :load_strategy

        def initialize(component_factory, env)
          logger.info "Request::Batch#initialize: id: #{env.data['batch_id']}" if env.data

          @batch_id          = env.data["batch_id"] if env.data
          @component_factory = component_factory
          @components        = components_for env
        end

        private

        def components_for(env)
          ((env.data || {}).fetch("components", []) || []).map do |c|
            @component_factory.create(
              c["component"],
              batch_id,
              c["options"]
            )
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alephant-broker-3.10.2 lib/alephant/broker/request/batch.rb