Class: Blix::Rest::FormatParser
- Inherits:
-
Object
- Object
- Blix::Rest::FormatParser
- Defined in:
- lib/blix/rest/format_parser.rb
Overview
this is the base class for all the format parsers
Direct Known Subclasses
HtmlFormatParser, JsonFormatParser, RawFormatParser, XmlFormatParser
Instance Attribute Summary collapse
-
#__custom_headers ⇒ Object
Returns the value of attribute __custom_headers.
-
#_format ⇒ Object
Returns the value of attribute _format.
- #_options ⇒ Object
Class Method Summary collapse
- ._types ⇒ Object
-
.accept_types(types) ⇒ Object
the accept header types that correspont to this parser.
Instance Method Summary collapse
- #_types ⇒ Object
-
#format_error(message) ⇒ Object
construct the body of an error messsage.
-
#format_response(value, response) ⇒ Object
set the response content / headers / status headers are the default headers if not set status is 200 if not set.
- #set_default_headers(headers) ⇒ Object
Instance Attribute Details
#__custom_headers ⇒ Object
Returns the value of attribute __custom_headers.
7 8 9 |
# File 'lib/blix/rest/format_parser.rb', line 7 def __custom_headers @__custom_headers end |
#_format ⇒ Object
Returns the value of attribute _format.
15 16 17 |
# File 'lib/blix/rest/format_parser.rb', line 15 def _format @_format end |
#_options ⇒ Object
19 20 21 |
# File 'lib/blix/rest/format_parser.rb', line 19 def @_options || {} end |
Class Method Details
._types ⇒ Object
27 28 29 |
# File 'lib/blix/rest/format_parser.rb', line 27 def self._types @_types || [] end |
.accept_types(types) ⇒ Object
the accept header types that correspont to this parser.
36 37 38 39 |
# File 'lib/blix/rest/format_parser.rb', line 36 def self.accept_types(types) types = [types].flatten @_types = types end |
Instance Method Details
#_types ⇒ Object
31 32 33 |
# File 'lib/blix/rest/format_parser.rb', line 31 def _types self.class._types end |
#format_error(message) ⇒ Object
construct the body of an error messsage.
42 43 44 |
# File 'lib/blix/rest/format_parser.rb', line 42 def format_error() .to_s end |
#format_response(value, response) ⇒ Object
set the response content / headers / status headers are the default headers if not set status is 200 if not set
49 50 51 |
# File 'lib/blix/rest/format_parser.rb', line 49 def format_response(value, response) response.content = value.to_s end |
#set_default_headers(headers) ⇒ Object
9 10 11 12 13 |
# File 'lib/blix/rest/format_parser.rb', line 9 def set_default_headers(headers) # headers[CACHE_CONTROL]= CACHE_NO_STORE # headers[PRAGMA] = NO_CACHE # headers[CONTENT_TYPE] = CONTENT_TYPE_JSON end |