Class: Blix::Rest::FormatParser

Inherits:
Object
  • Object
show all
Defined in:
lib/blix/rest/format_parser.rb

Overview

this is the base class for all the format parsers

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#__custom_headersObject

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

#_formatObject

Returns the value of attribute _format.



15
16
17
# File 'lib/blix/rest/format_parser.rb', line 15

def _format
  @_format
end

#_optionsObject



19
20
21
# File 'lib/blix/rest/format_parser.rb', line 19

def _options
  @_options || {}
end

Class Method Details

._typesObject



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

#_typesObject



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(message)
  message.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