Sha256: 58a4160f56911db674d13a37c552fdeaae81e95722eabe70704948aadc900c66

Contents?: true

Size: 903 Bytes

Versions: 15

Compression:

Stored size: 903 Bytes

Contents

require 'alephant/logger'
require 'alephant/broker/component'

module Alephant
  module Broker
    module Request
      class Multi
        include Logger

        attr_reader :requests

        def initialize(env)
          logger.debug("Request::Multi#initialize(#{env.settings})")
          @requests = requests_for env
        end

        private

        def requests_for(env)
          env.data['requests'].map do |c|
            case c['type']
            when 'asset'
              asset = Asset.new

              component_id = c['payload']['component_id']
              options      = c['payload']['options']

              component = Component.new(component_id, nil, options)
              asset.tap { |a| a.component = component }
            else
              raise StandardError.new "request type not identified"
            end
          end
        end

      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
alephant-broker-2.1.3 lib/alephant/broker/request/multi.rb
alephant-broker-2.1.2 lib/alephant/broker/request/multi.rb
alephant-broker-2.1.1 lib/alephant/broker/request/multi.rb
alephant-broker-2.1.0 lib/alephant/broker/request/multi.rb
alephant-broker-2.0.3 lib/alephant/broker/request/multi.rb
alephant-broker-2.0.2 lib/alephant/broker/request/multi.rb
alephant-broker-2.0.1 lib/alephant/broker/request/multi.rb
alephant-broker-2.0.0 lib/alephant/broker/request/multi.rb
alephant-broker-1.3.1 lib/alephant/broker/request/multi.rb
alephant-broker-1.2.1 lib/alephant/broker/request/multi.rb
alephant-broker-1.2.0 lib/alephant/broker/request/multi.rb
alephant-broker-1.1.3 lib/alephant/broker/request/multi.rb
alephant-broker-1.1.2 lib/alephant/broker/request/multi.rb
alephant-broker-1.1.1 lib/alephant/broker/request/multi.rb
alephant-broker-1.1.0 lib/alephant/broker/request/multi.rb