Sha256: 1d5e0dd61d9822e1e141b41960dfa95e98542ac6c2765671ed1659fbf681fb0a

Contents?: true

Size: 1 KB

Versions: 18

Compression:

Stored size: 1 KB

Contents

require 'alephant/logger'

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})"
          components.map do |component|
            {
              'component'    => component.id,
              'options'      => component.options,
              'status'       => component.status,
              'content_type' => component.content_type,
              'body'         => component.content
            }
          end.tap { logger.info "Broker: Batch load done (#{batch_id})" }
        end

      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
alephant-broker-3.5.4 lib/alephant/broker/response/batch.rb
alephant-broker-3.5.3 lib/alephant/broker/response/batch.rb
alephant-broker-3.5.2 lib/alephant/broker/response/batch.rb
alephant-broker-3.5.1 lib/alephant/broker/response/batch.rb
alephant-broker-3.5.0 lib/alephant/broker/response/batch.rb
alephant-broker-3.4.1 lib/alephant/broker/response/batch.rb
alephant-broker-3.4.0 lib/alephant/broker/response/batch.rb
alephant-broker-3.3.2 lib/alephant/broker/response/batch.rb
alephant-broker-3.3.1 lib/alephant/broker/response/batch.rb
alephant-broker-3.3.0 lib/alephant/broker/response/batch.rb
alephant-broker-3.2.0 lib/alephant/broker/response/batch.rb
alephant-broker-3.1.1 lib/alephant/broker/response/batch.rb
alephant-broker-3.1.0 lib/alephant/broker/response/batch.rb
alephant-broker-3.0.1 lib/alephant/broker/response/batch.rb
alephant-broker-3.0.0 lib/alephant/broker/response/batch.rb
alephant-broker-2.1.3 lib/alephant/broker/response/batch.rb
alephant-broker-2.1.2 lib/alephant/broker/response/batch.rb
alephant-broker-2.1.1 lib/alephant/broker/response/batch.rb