Class: Alephant::Broker::Component
- Inherits:
-
Object
- Object
- Alephant::Broker::Component
- Defined in:
- lib/alephant/broker/component.rb
Constant Summary collapse
- HEADER_PREFIX =
"head_"
Instance Attribute Summary collapse
-
#batch_id ⇒ Object
readonly
Returns the value of attribute batch_id.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#opts_hash ⇒ Object
readonly
Returns the value of attribute opts_hash.
Instance Method Summary collapse
- #content_type ⇒ Object
- #headers ⇒ Object
-
#initialize(meta, data) ⇒ Component
constructor
A new instance of Component.
- #status ⇒ Object
Constructor Details
#initialize(meta, data) ⇒ Component
Returns a new instance of Component.
15 16 17 18 19 20 21 22 23 |
# File 'lib/alephant/broker/component.rb', line 15 def initialize(, data) @id = .id @batch_id = .batch_id @options = symbolize(. || {}) @content = data[:content].force_encoding "UTF-8" @opts_hash = .opts_hash @data = data @meta = end |
Instance Attribute Details
#batch_id ⇒ Object (readonly)
Returns the value of attribute batch_id.
11 12 13 |
# File 'lib/alephant/broker/component.rb', line 11 def batch_id @batch_id end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
11 12 13 |
# File 'lib/alephant/broker/component.rb', line 11 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
11 12 13 |
# File 'lib/alephant/broker/component.rb', line 11 def id @id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/alephant/broker/component.rb', line 11 def @options end |
#opts_hash ⇒ Object (readonly)
Returns the value of attribute opts_hash.
11 12 13 |
# File 'lib/alephant/broker/component.rb', line 11 def opts_hash @opts_hash end |
Instance Method Details
#content_type ⇒ Object
25 26 27 |
# File 'lib/alephant/broker/component.rb', line 25 def content_type headers["Content-Type"] end |
#headers ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/alephant/broker/component.rb', line 29 def headers { "Content-Type" => data[:content_type].to_s } .merge(data[:headers] || {}) .merge() end |
#status ⇒ Object
37 38 39 |
# File 'lib/alephant/broker/component.rb', line 37 def status data[:meta].key?("status") ? data[:meta]["status"] : 200 end |