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_converter) ⇒ Response

Returns a new instance of Response.



12
13
14
15
16
# File 'lib/soapy_cake/response.rb', line 12

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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#short_responseObject (readonly)

Returns the value of attribute short_response.



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

def short_response
  @short_response
end

#time_converterObject (readonly)

Returns the value of attribute time_converter.



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

def time_converter
  @time_converter
end

Instance Method Details

#to_enumObject



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

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



30
31
32
33
34
# File 'lib/soapy_cake/response.rb', line 30

def to_xml
  check_errors!

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