Class: DynamicsCRM::XML::ConditionExpression
- Inherits:
-
Object
- Object
- DynamicsCRM::XML::ConditionExpression
- Defined in:
- lib/dynamics_crm/xml/condition_expression.rb
Overview
Loosely based on msdn.microsoft.com/en-us/library/gg334419.aspx Creates a ConditionExpression element to be used in retrieve calls.
Instance Attribute Summary collapse
-
#attr_name ⇒ Object
Returns the value of attribute attr_name.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(attr_name, operator, value = nil, type: nil) ⇒ ConditionExpression
constructor
A new instance of ConditionExpression.
- #to_xml(options = {}) ⇒ Object
- #value_type ⇒ Object
Constructor Details
#initialize(attr_name, operator, value = nil, type: nil) ⇒ ConditionExpression
Returns a new instance of ConditionExpression.
8 9 10 11 12 13 14 15 |
# File 'lib/dynamics_crm/xml/condition_expression.rb', line 8 def initialize(attr_name, operator, value = nil, type: nil) @attr_name = attr_name @operator = operator # value can be optional to support Null and NotNull operators @value = value @values = Array(value) @type = type end |
Instance Attribute Details
#attr_name ⇒ Object
Returns the value of attribute attr_name.
6 7 8 |
# File 'lib/dynamics_crm/xml/condition_expression.rb', line 6 def attr_name @attr_name end |
#operator ⇒ Object
Returns the value of attribute operator.
6 7 8 |
# File 'lib/dynamics_crm/xml/condition_expression.rb', line 6 def operator @operator end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/dynamics_crm/xml/condition_expression.rb', line 6 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/dynamics_crm/xml/condition_expression.rb', line 6 def value @value end |
Instance Method Details
#to_xml(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dynamics_crm/xml/condition_expression.rb', line 30 def to_xml( = {}) ns = [:namespace] ? [:namespace] : 'a' expression = %(<#{ns}:ConditionExpression> <#{ns}:AttributeName>#{attr_name}</#{ns}:AttributeName> <#{ns}:Operator>#{operator}</#{ns}:Operator> <#{ns}:Values xmlns:d="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> ) @values.each do |v| expression << %(<d:anyType i:type="s:#{value_type}" xmlns:s="http://www.w3.org/2001/XMLSchema">#{v}</d:anyType>) end expression << %( </#{ns}:Values> </#{ns}:ConditionExpression>) expression end |
#value_type ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dynamics_crm/xml/condition_expression.rb', line 17 def value_type return type unless type.nil? type = @values.first.class.to_s.downcase if type == 'fixnum' type = 'int' elsif %w(trueclass falseclass).include?(type) type = 'boolean' end type end |