Class: Datacash::Request::Base

Inherits:
Hash
  • Object
show all
Includes:
Hashie::Extensions::Coercion, Hashie::Extensions::MergeInitializer
Defined in:
lib/datacash/request/base.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
# File 'lib/datacash/request/base.rb', line 7

def initialize(*args)
  self.class.keys.each do |key, options|
    self[key] = options.fetch(:default, nil)
  end
  super
end

Class Method Details

.key(key, options = {}) ⇒ Object



18
19
20
# File 'lib/datacash/request/base.rb', line 18

def self.key(key, options={})
  keys[key] = options
end

.keysObject



14
15
16
# File 'lib/datacash/request/base.rb', line 14

def self.keys
  @keys ||= {}
end

.root(name = nil) ⇒ Object



22
23
24
25
# File 'lib/datacash/request/base.rb', line 22

def self.root(name=nil)
  @root = name if name
  @root
end

Instance Method Details

#to_xml(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/datacash/request/base.rb', line 27

def to_xml(options = {})
  super(options.merge(
    root: self.class.root,
    skip_types: true,
    indent: 0,
    dasherize: false
  ))
end