Sha256: 8dd3dcbb2c5fab751abf0eddd951bb919db7571028ce48fd92a08c7dd06c7313
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
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) @batch_id = if env.data env.data["batch_id"] else env.options.fetch("batch_id", nil) end logger.debug( method: "Request::Batch#initialize", id: batch_id, ) @component_factory = component_factory @components = env.post? ? components_post(env) : components_get(env) end private def components_post(env) ((env.data || {}).fetch("components", []) || []).map do |c| create_component(c["component"], batch_id, c["options"]) end end def components_get(env) (env.options.fetch("components", []) || []).map do |c| options = c[1].fetch("options", {}) || {} create_component(c[1]["component"], batch_id, options) end end def create_component(component, batch_id, options) @component_factory.create(component, batch_id, options) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
alephant-broker-3.19.1 | lib/alephant/broker/request/batch.rb |
alephant-broker-3.19.0 | lib/alephant/broker/request/batch.rb |