Class: Moon::Response::XML

Inherits:
Base
  • Object
show all
Defined in:
lib/moon/response/xml.rb

Overview

Moon::Response::XML is the base class for all xml responses.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, hash = { }) ⇒ XML

Returns a new instance of XML.



9
10
11
# File 'lib/moon/response/xml.rb', line 9

def initialize(status, hash = { })
  @status, @hash = status, hash
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



7
8
9
# File 'lib/moon/response/xml.rb', line 7

def hash
  @hash
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/moon/response/xml.rb', line 6

def status
  @status
end

Instance Method Details

#bodyObject



17
18
19
20
21
# File 'lib/moon/response/xml.rb', line 17

def body
  XmlSimple.xml_out @hash,
                    "XmlDeclaration" => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
                    "KeepRoot" => true
end

#headersObject



13
14
15
# File 'lib/moon/response/xml.rb', line 13

def headers
  { "Content-Type" => "text/xml" }
end