Sha256: 5570469c7e8439032a83f4eb2affd9adf1eaf63c629da6510207f4abea3a6a5a

Contents?: true

Size: 935 Bytes

Versions: 12

Compression:

Stored size: 935 Bytes

Contents

require 'alephant/logger'
require 'peach'

module Alephant
  module Broker
    module Response
      class Batch < Base
        include Logger

        attr_reader :components, :batch_id

        def initialize(components, batch_id)
          @components = components
          @batch_id   = batch_id

          super(200, 'application/json')
        end

        def setup
          @content = JSON.generate({
            "batch_id" => batch_id,
            "components" => json
          })
        end

        private

        def json
          logger.info("Broker: Batch load started (#{batch_id})")
          result = components.pmap do | component |
            {
              'component' => component.id,
              'options'   => component.options
            }.merge load(component)
          end
          logger.info("Broker: Batch load done (#{batch_id})")

          result
        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
alephant-broker-1.2.1 lib/alephant/broker/response/batch.rb
alephant-broker-1.2.0 lib/alephant/broker/response/batch.rb
alephant-broker-1.1.3 lib/alephant/broker/response/batch.rb
alephant-broker-1.1.2 lib/alephant/broker/response/batch.rb
alephant-broker-1.1.1 lib/alephant/broker/response/batch.rb
alephant-broker-1.1.0 lib/alephant/broker/response/batch.rb
alephant-broker-1.0.5 lib/alephant/broker/response/batch.rb
alephant-broker-1.0.4 lib/alephant/broker/response/batch.rb
alephant-broker-1.0.3 lib/alephant/broker/response/batch.rb
alephant-broker-1.0.2 lib/alephant/broker/response/batch.rb
alephant-broker-1.0.1 lib/alephant/broker/response/batch.rb
alephant-broker-1.0.0 lib/alephant/broker/response/batch.rb