Class: SoapyCake::Response

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/soapy_cake/response.rb

Constant Summary collapse

SHORT_ELEMENT_DEPTH =
3
ELEMENTS_DEPTH =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#const_lookup, #future_expiration_date, #require_params, #translate_booleans, #translate_values, #validate_id, #walk_tree

Constructor Details

#initialize(body, short_response, time_offset) ⇒ Response

Returns a new instance of Response.



10
11
12
13
14
# File 'lib/soapy_cake/response.rb', line 10

def initialize(body, short_response, time_offset)
  @body = body
  @short_response = short_response
  @time_offset = time_offset
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



8
9
10
# File 'lib/soapy_cake/response.rb', line 8

def body
  @body
end

#short_responseObject (readonly)

Returns the value of attribute short_response.



8
9
10
# File 'lib/soapy_cake/response.rb', line 8

def short_response
  @short_response
end

#time_offsetObject (readonly)

Returns the value of attribute time_offset.



8
9
10
# File 'lib/soapy_cake/response.rb', line 8

def time_offset
  @time_offset
end

Instance Method Details

#to_enumObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/soapy_cake/response.rb', line 16

def to_enum
  check_errors!

  return typed_element(sax.at_depth(SHORT_ELEMENT_DEPTH).first) if short_response

  Enumerator.new do |y|
    sax.at_depth(ELEMENTS_DEPTH).each do |element|
      y << typed_element(element)
    end
  end
end

#to_xmlObject



28
29
30
# File 'lib/soapy_cake/response.rb', line 28

def to_xml
  (empty? ? [] : [body.to_s]).to_enum
end