Class: DynamicsCRM::XML::Query
- Inherits:
-
Object
- Object
- DynamicsCRM::XML::Query
- Defined in:
- lib/dynamics_crm/xml/query.rb
Overview
Represents Query XML fragment.
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#criteria ⇒ Object
Returns the value of attribute criteria.
-
#entity_name ⇒ Object
Returns the value of attribute entity_name.
Instance Method Summary collapse
-
#initialize(entity_name) ⇒ Query
constructor
A new instance of Query.
- #to_xml(options = {}) ⇒ Object
Constructor Details
#initialize(entity_name) ⇒ Query
Returns a new instance of Query.
8 9 10 |
# File 'lib/dynamics_crm/xml/query.rb', line 8 def initialize(entity_name) @entity_name = entity_name end |
Instance Attribute Details
#columns ⇒ Object
Returns the value of attribute columns.
6 7 8 |
# File 'lib/dynamics_crm/xml/query.rb', line 6 def columns @columns end |
#criteria ⇒ Object
Returns the value of attribute criteria.
6 7 8 |
# File 'lib/dynamics_crm/xml/query.rb', line 6 def criteria @criteria end |
#entity_name ⇒ Object
Returns the value of attribute entity_name.
6 7 8 |
# File 'lib/dynamics_crm/xml/query.rb', line 6 def entity_name @entity_name end |
Instance Method Details
#to_xml(options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dynamics_crm/xml/query.rb', line 12 def to_xml(={}) namespace = [:namespace] ? [:namespace] : "b" column_set = ColumnSet.new(columns) @criteria ||= Criteria.new xml = %Q{ #{column_set.to_xml(namespace: namespace, camel_case: true)} #{@criteria.to_xml(namespace: namespace)} <#{namespace}:Distinct>false</#{namespace}:Distinct> <#{namespace}:EntityName>#{entity_name}</#{namespace}:EntityName> <#{namespace}:LinkEntities /> <#{namespace}:Orders /> } if [:exclude_root].nil? xml = %Q{<query i:type="b:QueryExpression" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> #{xml} </query>} end return xml end |