Sha256: 568ec3ebe07d700dfcc7be4ec86ed593d36e31fa0b8ebeeb503715cdf8ef4e19
Contents?: true
Size: 1.16 KB
Versions: 15
Compression:
Stored size: 1.16 KB
Contents
require 'json' module Alephant module Broker module Response class Multi < Base attr_reader :requests POLLING_DELAY = 2 def initialize(requests) @requests = requests super() end def raw_response requests.reduce(:delay => POLLING_DELAY, :responses => []) do |m,request| response = Factory.response_for request case response when Asset m[:responses] << { :type => response.class.to_s.downcase, :datatype => response.content_type, :payload => { :component_id => response.component.id, :options => response.component.options, :body => response.to_h } } when NotFound # Do nothing else raise StandardError.new "response type not identified" end m end end def setup @content_type = 'application/json' @content = JSON.generate(raw_response) end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems