Module: Sinatra::Ace::Helper
- Defined in:
- lib/sinatra/ace.rb
Instance Method Summary collapse
- #attributes ⇒ Object
- #error_xml(type, code, message) ⇒ Object
- #request_id ⇒ Object
- #requested_action ⇒ Object
- #requested_version ⇒ Object
- #response_xml ⇒ Object
Instance Method Details
#attributes ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/sinatra/ace.rb', line 18 def attributes @attributes ||= (1..10).to_a.inject({}) do |attributes, i| if (name = params["Attribute.#{i.to_s}.Name"]) && (value = params["Attribute.#{i.to_s}.Value"]) attributes[name] = value end attributes end end |
#error_xml(type, code, message) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/sinatra/ace.rb', line 39 def error_xml(type, code, ) builder do |xml| xml.instruct! xml.ErrorResponse do xml.Error do xml.Type type xml.Code code xml.Message end xml.ResponseMetadata { xml.RequestId request_id } end end end |
#request_id ⇒ Object
6 7 8 |
# File 'lib/sinatra/ace.rb', line 6 def request_id @request_id ||= SecureRandom.uuid end |
#requested_action ⇒ Object
10 11 12 |
# File 'lib/sinatra/ace.rb', line 10 def requested_action params['Action'] end |
#requested_version ⇒ Object
14 15 16 |
# File 'lib/sinatra/ace.rb', line 14 def requested_version params['Version'] end |
#response_xml ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sinatra/ace.rb', line 27 def response_xml builder do |xml| xml.instruct! xml.tag!("#{requested_action}Response") do xml.tag!("#{requested_action}Result") do yield(xml) end xml.ResponseMetadata { xml.RequestId request_id } end end end |