Class: Rabl::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rabl/configuration.rb

Overview

Rabl.host

Constant Summary collapse

DEFAULT_XML_OPTIONS =
{ :dasherize  => true, :skip_types => false }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
# File 'lib/rabl/configuration.rb', line 11

def initialize
  @include_json_root     = true
  @include_xml_root      = false
  @enable_json_callbacks = false
  @xml_options           = {}
end

Instance Attribute Details

#enable_json_callbacksObject

Returns the value of attribute enable_json_callbacks.



6
7
8
# File 'lib/rabl/configuration.rb', line 6

def enable_json_callbacks
  @enable_json_callbacks
end

#include_json_rootObject

Returns the value of attribute include_json_root.



4
5
6
# File 'lib/rabl/configuration.rb', line 4

def include_json_root
  @include_json_root
end

#include_xml_rootObject

Returns the value of attribute include_xml_root.



5
6
7
# File 'lib/rabl/configuration.rb', line 5

def include_xml_root
  @include_xml_root
end

#xml_options=(value) ⇒ Object (writeonly)

Sets the attribute xml_options

Parameters:

  • value

    the value to set the attribute xml_options to.



7
8
9
# File 'lib/rabl/configuration.rb', line 7

def xml_options=(value)
  @xml_options = value
end

Instance Method Details

#[](option) ⇒ Object

Allows config options to be read like a hash

Parameters:

  • option (Symbol)

    Key for a given attribute



21
22
23
# File 'lib/rabl/configuration.rb', line 21

def [](option)
  send(option)
end

#default_xml_optionsObject

Returns merged default and inputted xml options



26
27
28
# File 'lib/rabl/configuration.rb', line 26

def default_xml_options
  @_default_xml_options ||= @xml_options.reverse_merge(DEFAULT_XML_OPTIONS)
end