Class: Rabl::Configuration
- Inherits:
-
Object
- Object
- Rabl::Configuration
- Defined in:
- lib/rabl/configuration.rb
Overview
Rabl.host
Constant Summary collapse
- DEFAULT_XML_OPTIONS =
{ :dasherize => true, :skip_types => false }
Instance Attribute Summary collapse
-
#enable_json_callbacks ⇒ Object
Returns the value of attribute enable_json_callbacks.
-
#include_json_root ⇒ Object
Returns the value of attribute include_json_root.
-
#include_msgpack_root ⇒ Object
Returns the value of attribute include_msgpack_root.
-
#include_xml_root ⇒ Object
Returns the value of attribute include_xml_root.
-
#msgpack_engine ⇒ Object
The MessagePack encoder/engine to use.
-
#xml_options ⇒ Object
writeonly
Sets the attribute xml_options.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
-
#default_xml_options ⇒ Object
Returns merged default and inputted xml options.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#json_engine ⇒ Object
The JSON engine used to encode Rabl templates into JSON.
- #json_engine=(engine_name_or_class) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 30 |
# File 'lib/rabl/configuration.rb', line 22 def initialize @include_json_root = true @include_msgpack_root = true @include_xml_root = false @enable_json_callbacks = false @json_engine = nil @msgpack_engine = nil @xml_options = {} end |
Instance Attribute Details
#enable_json_callbacks ⇒ Object
Returns the value of attribute enable_json_callbacks.
16 17 18 |
# File 'lib/rabl/configuration.rb', line 16 def enable_json_callbacks @enable_json_callbacks end |
#include_json_root ⇒ Object
Returns the value of attribute include_json_root.
13 14 15 |
# File 'lib/rabl/configuration.rb', line 13 def include_json_root @include_json_root end |
#include_msgpack_root ⇒ Object
Returns the value of attribute include_msgpack_root.
14 15 16 |
# File 'lib/rabl/configuration.rb', line 14 def include_msgpack_root @include_msgpack_root end |
#include_xml_root ⇒ Object
Returns the value of attribute include_xml_root.
15 16 17 |
# File 'lib/rabl/configuration.rb', line 15 def include_xml_root @include_xml_root end |
#msgpack_engine ⇒ Object
Returns the MessagePack encoder/engine to use.
46 47 48 |
# File 'lib/rabl/configuration.rb', line 46 def msgpack_engine @msgpack_engine || ::MessagePack end |
#xml_options=(value) ⇒ Object (writeonly)
Sets the attribute xml_options
18 19 20 |
# File 'lib/rabl/configuration.rb', line 18 def (value) @xml_options = value end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
53 54 55 |
# File 'lib/rabl/configuration.rb', line 53 def [](option) send(option) end |
#default_xml_options ⇒ Object
Returns merged default and inputted xml options
58 59 60 |
# File 'lib/rabl/configuration.rb', line 58 def @_default_xml_options ||= @xml_options.reverse_merge(DEFAULT_XML_OPTIONS) end |
#json_engine ⇒ Object
Returns The JSON engine used to encode Rabl templates into JSON.
40 41 42 |
# File 'lib/rabl/configuration.rb', line 40 def json_engine get_json_engine end |
#json_engine=(engine_name_or_class) ⇒ Object
35 36 37 |
# File 'lib/rabl/configuration.rb', line 35 def json_engine=(engine_name_or_class) MultiJson.engine = @engine_name = engine_name_or_class end |