Class: DynamicsCRM::FetchXml::Builder
- Inherits:
-
Object
- Object
- DynamicsCRM::FetchXml::Builder
- Defined in:
- lib/dynamics_crm/fetch_xml/builder.rb
Instance Attribute Summary collapse
-
#distinct ⇒ Object
Returns the value of attribute distinct.
-
#mapping ⇒ Object
Returns the value of attribute mapping.
-
#output_format ⇒ Object
Returns the value of attribute output_format.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #entity(logical_name) ⇒ Object
-
#initialize(options = {}) ⇒ Builder
constructor
A new instance of Builder.
- #to_xml ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Builder
Returns a new instance of Builder.
32 33 34 35 36 37 38 39 40 |
# File 'lib/dynamics_crm/fetch_xml/builder.rb', line 32 def initialize(={}) @entities = [] @link_entities = [] @version = [:version] || '1.0' @output_format = [:output_format] || 'xml-platform' @mapping = [:mapping] || 'logical' @distinct = [:distinct] || false end |
Instance Attribute Details
#distinct ⇒ Object
Returns the value of attribute distinct.
30 31 32 |
# File 'lib/dynamics_crm/fetch_xml/builder.rb', line 30 def distinct @distinct end |
#mapping ⇒ Object
Returns the value of attribute mapping.
30 31 32 |
# File 'lib/dynamics_crm/fetch_xml/builder.rb', line 30 def mapping @mapping end |
#output_format ⇒ Object
Returns the value of attribute output_format.
30 31 32 |
# File 'lib/dynamics_crm/fetch_xml/builder.rb', line 30 def output_format @output_format end |
#version ⇒ Object
Returns the value of attribute version.
30 31 32 |
# File 'lib/dynamics_crm/fetch_xml/builder.rb', line 30 def version @version end |
Instance Method Details
#entity(logical_name) ⇒ Object
42 43 44 45 |
# File 'lib/dynamics_crm/fetch_xml/builder.rb', line 42 def entity(logical_name) @entities << Entity.new(logical_name) @entities.last end |
#to_xml ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dynamics_crm/fetch_xml/builder.rb', line 47 def to_xml @builder = ::Builder::XmlMarkup.new(:indent=>2) # <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"> @builder.fetch(version: @version, :"output-format" => @output_format, mapping: @mapping, distinct: @distinct) { @entities.each do |e| # <entity name="opportunityproduct"> @builder.entity(name: e.logical_name) { e.attributes.each do |field| # <attribute name="productid" /> @builder.attribute(name: field) end if e.order_field @builder.order(attribute: e.order_field, descending: e.order_desc) end add_link_entities(e) if e.has_conditions? # <filter type="and"> @builder.filter(type: 'and') { e.conditions.each do |c| # <condition attribute="opportunityid" operator="eq" value="02dd7344-d04a-e411-a9d3-9cb654950300" /> @builder.condition(attribute: c[:attribute], operator: c[:operator], value: c[:value]) end } end # </entity> } end } @builder.target! end |