Class: Quickbooks::Qbxml::RequestSet
- Includes:
- Enumerable
- Defined in:
- lib/quickbooks/qbxml/request.rb
Instance Method Summary collapse
- #<<(qbxml_request) ⇒ Object
-
#initialize(*requests) ⇒ RequestSet
constructor
A new instance of RequestSet.
- #set ⇒ Object
- #to_xml ⇒ Object
Constructor Details
#initialize(*requests) ⇒ RequestSet
Returns a new instance of RequestSet.
29 30 31 |
# File 'lib/quickbooks/qbxml/request.rb', line 29 def initialize(*requests) self << requests end |
Instance Method Details
#<<(qbxml_request) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/quickbooks/qbxml/request.rb', line 17 def <<(qbxml_request) if qbxml_request.is_a?(Quickbooks::Qbxml::Request) set << qbxml_request elsif qbxml_request.respond_to?(:each) qbxml_request.each do |request| self << request end else raise ArgumentError, "Cannot add object of type #{qbxml_request.class.name} to a Quickbooks::Qbxml::RequestSet" end end |
#set ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/quickbooks/qbxml/request.rb', line 9 def set unless @set.is_a?(Array) @set = [] @set.extend(Quickbooks::Qbxml::RequestSetArrayExt) end @set end |
#to_xml ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/quickbooks/qbxml/request.rb', line 33 def to_xml pre = <<-thequickbooks_qbxmlrequestsetxml <?xml version="1.0" ?> <?qbxml version="#{Quickbooks::Qbxml::VERSION}" ?> <QBXML> <QBXMLMsgsRq onError="stopOnError"> thequickbooks_qbxmlrequestsetxml requests = map {|x| x.to_xml(false)}.join post = <<-thequickbooks_qbxmlrequestsetxml </QBXMLMsgsRq> </QBXML> thequickbooks_qbxmlrequestsetxml # puts pre + requests + post pre + requests + post end |