Class: Alephant::Broker::Response::Base

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

Direct Known Subclasses

Asset, Batch, NotFound, ServerError, Status

Constant Summary collapse

STATUS_CODE_MAPPING =
{
  200 => "ok",
  404 => "Not found",
  500 => "Error retrieving content"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status = 200, content_type = "text/html") ⇒ Base

Returns a new instance of Base.



21
22
23
24
25
26
27
28
29
# File 'lib/alephant/broker/response/base.rb', line 21

def initialize(status = 200, content_type = "text/html")
  @content = STATUS_CODE_MAPPING[status]
  @headers = { "Content-Type" => content_type }
  @headers.merge!(Broker.config[:headers]) if Broker.config.has_key?(:headers)
  @status  = status

  log_status
  setup
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



13
14
15
# File 'lib/alephant/broker/response/base.rb', line 13

def content
  @content
end

#headersObject (readonly)

Returns the value of attribute headers.



13
14
15
# File 'lib/alephant/broker/response/base.rb', line 13

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'lib/alephant/broker/response/base.rb', line 13

def status
  @status
end