Class: DynamicsCRM::Metadata::PropertiesExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamics_crm/metadata/properties_expression.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(properties = []) ⇒ PropertiesExpression

Returns a new instance of PropertiesExpression.



7
8
9
# File 'lib/dynamics_crm/metadata/properties_expression.rb', line 7

def initialize(properties=[])
  @properties = properties
end

Instance Attribute Details

#propertiesObject

Returns the value of attribute properties.



5
6
7
# File 'lib/dynamics_crm/metadata/properties_expression.rb', line 5

def properties
  @properties
end

Instance Method Details

#to_xml(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dynamics_crm/metadata/properties_expression.rb', line 11

def to_xml(options={})
  namespace = options[:namespace] ? options[:namespace] + ":" : ""

  property_set = ''
  if @properties.any?
    property_set = %Q{<#{namespace}PropertyNames xmlns:e="http://schemas.microsoft.com/2003/10/Serialization/Arrays">}
    @properties.each do |name|
      property_set << "<e:string>#{name}</e:string>"
    end
    property_set << "</#{namespace}PropertyNames>"
  end

  %Q{<#{namespace}Properties>
       <#{namespace}AllProperties>#{property_set.empty?}</#{namespace}AllProperties>
       #{property_set}
     </#{namespace}Properties>}
end