Class: Tilia::Http::ResponseDecorator

Inherits:
Object
  • Object
show all
Includes:
MessageDecoratorTrait, ResponseInterface
Defined in:
lib/tilia/http/response_decorator.rb

Overview

Response Decorator

This helper class allows you to easily create decorators for the Response object.

Instance Method Summary collapse

Methods included from MessageDecoratorTrait

#add_header, #add_headers, #body, #body=, #body_as_stream, #body_as_string, #header, #header?, #header_as_array, #headers, #http_version, #http_version=, #remove_header, #update_header, #update_headers

Methods included from MessageInterface

#add_header, #add_headers, #body, #body=, #body_as_stream, #body_as_string, #header, #header?, #header_as_array, #headers, #http_version, #http_version=, #remove_header, #update_header, #update_headers

Constructor Details

#initialize(inner) ⇒ ResponseDecorator

Constructor.



14
15
16
# File 'lib/tilia/http/response_decorator.rb', line 14

def initialize(inner)
  @inner = inner
end

Instance Method Details

#statusObject

Returns the current HTTP status code.



21
22
23
# File 'lib/tilia/http/response_decorator.rb', line 21

def status
  @inner.status
end

#status=(status) ⇒ void

This method returns an undefined value.

Sets the HTTP status code.

This can be either the full HTTP status code with human readable string, for example: “403 I can’t let you do that, Dave”.

Or just the code, in which case the appropriate default message will be added.



44
45
46
# File 'lib/tilia/http/response_decorator.rb', line 44

def status=(status)
  @inner.status = status
end

#status_textString

Returns the human-readable status string.

In the case of a 200, this may for example be ‘OK’.



30
31
32
# File 'lib/tilia/http/response_decorator.rb', line 30

def status_text
  @inner.status_text
end

#to_sString

Serializes the request object as a string.

This is useful for debugging purposes.



53
54
55
# File 'lib/tilia/http/response_decorator.rb', line 53

def to_s
  @inner.to_s
end