Class: Alephant::Broker::Response::Batch

Inherits:
Base
  • Object
show all
Includes:
Logger
Defined in:
lib/alephant/broker/response/batch.rb

Constant Summary

Constants inherited from Base

Alephant::Broker::Response::Base::NOT_MODIFIED_STATUS_CODE, Alephant::Broker::Response::Base::STATUS_CODE_MAPPING

Instance Attribute Summary collapse

Attributes inherited from Base

#content, #headers, #status

Instance Method Summary collapse

Constructor Details

#initialize(components, batch_id, request_env) ⇒ Batch

Returns a new instance of Batch.



12
13
14
15
16
17
18
19
20
# File 'lib/alephant/broker/response/batch.rb', line 12

def initialize(components, batch_id, request_env)
  @components  = components
  @batch_id    = batch_id
  @status      = self.class.component_not_modified(batch_response_headers, request_env) ? NOT_MODIFIED_STATUS_CODE : 200

  super(@status, "application/json", request_env)

  @headers.merge!(batch_response_headers)
end

Instance Attribute Details

#batch_idObject (readonly)

Returns the value of attribute batch_id.



10
11
12
# File 'lib/alephant/broker/response/batch.rb', line 10

def batch_id
  @batch_id
end

#componentsObject (readonly)

Returns the value of attribute components.



10
11
12
# File 'lib/alephant/broker/response/batch.rb', line 10

def components
  @components
end

Instance Method Details

#setupObject



22
23
24
25
# File 'lib/alephant/broker/response/batch.rb', line 22

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