Class: AutotaskRuby::QueryXML
- Inherits:
-
Object
- Object
- AutotaskRuby::QueryXML
- Defined in:
- lib/autotask_ruby/query_xml.rb
Defined Under Namespace
Classes: Condition
Instance Attribute Summary collapse
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#entity ⇒ Object
Returns the value of attribute entity.
-
#expression ⇒ Object
Returns the value of attribute expression.
-
#field ⇒ Object
Returns the value of attribute field.
-
#op ⇒ Object
Returns the value of attribute op.
Instance Method Summary collapse
- #add_condition(field, op, expression) ⇒ Object
-
#initialize {|_self| ... } ⇒ QueryXML
constructor
A new instance of QueryXML.
- #to_s ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ QueryXML
Returns a new instance of QueryXML.
11 12 13 14 |
# File 'lib/autotask_ruby/query_xml.rb', line 11 def initialize yield self self.op ||= 'equals' end |
Instance Attribute Details
#conditions ⇒ Object
Returns the value of attribute conditions.
9 10 11 |
# File 'lib/autotask_ruby/query_xml.rb', line 9 def conditions @conditions end |
#entity ⇒ Object
Returns the value of attribute entity.
9 10 11 |
# File 'lib/autotask_ruby/query_xml.rb', line 9 def entity @entity end |
#expression ⇒ Object
Returns the value of attribute expression.
9 10 11 |
# File 'lib/autotask_ruby/query_xml.rb', line 9 def expression @expression end |
#field ⇒ Object
Returns the value of attribute field.
9 10 11 |
# File 'lib/autotask_ruby/query_xml.rb', line 9 def field @field end |
#op ⇒ Object
Returns the value of attribute op.
9 10 11 |
# File 'lib/autotask_ruby/query_xml.rb', line 9 def op @op end |
Instance Method Details
#add_condition(field, op, expression) ⇒ Object
16 17 18 19 |
# File 'lib/autotask_ruby/query_xml.rb', line 16 def add_condition(field, op, expression) self.conditions ||= [] self.conditions << Condition.new(field, op, expression) end |
#to_s ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/autotask_ruby/query_xml.rb', line 21 def to_s Nokogiri::XML::Builder.new do sXML do cdata(Nokogiri::XML::Builder.new do |xml| xml.queryxml do xml.entity entity xml.query do if field xml.field field do xml.expression expression, op: op end else conditions.each do |condition| xml.condition do xml.field condition.field do xml.expression condition.expression, op: condition.op end end end end end end end.doc.root) end end.doc.root.to_xml end |