Class: DynamicsCRM::XML::EntityReference
- Inherits:
-
Object
- Object
- DynamicsCRM::XML::EntityReference
- Defined in:
- lib/dynamics_crm/xml/entity_reference.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#logical_name ⇒ Object
Returns the value of attribute logical_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(logical_name, id) ⇒ EntityReference
constructor
A new instance of EntityReference.
- #to_hash ⇒ Object
- #to_xml(options = {}) ⇒ Object
Constructor Details
#initialize(logical_name, id) ⇒ EntityReference
Returns a new instance of EntityReference.
8 9 10 11 |
# File 'lib/dynamics_crm/xml/entity_reference.rb', line 8 def initialize(logical_name, id) @logical_name = logical_name @id = id || "00000000-0000-0000-0000-000000000000" end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/dynamics_crm/xml/entity_reference.rb', line 6 def id @id end |
#logical_name ⇒ Object
Returns the value of attribute logical_name.
6 7 8 |
# File 'lib/dynamics_crm/xml/entity_reference.rb', line 6 def logical_name @logical_name end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/dynamics_crm/xml/entity_reference.rb', line 6 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
6 7 8 |
# File 'lib/dynamics_crm/xml/entity_reference.rb', line 6 def namespace @namespace end |
Class Method Details
.from_xml(xml_document) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/dynamics_crm/xml/entity_reference.rb', line 39 def self.from_xml(xml_document) entity_ref = EntityReference.new('unknown', nil) if xml_document xml_document.each_element do |node| attr_name = ::DynamicsCRM::StringUtil.underscore(node.name).to_sym if entity_ref.respond_to?(attr_name) entity_ref.send("#{attr_name}=", node.text ? node.text.strip : nil) end end end return entity_ref end |
Instance Method Details
#to_hash ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/dynamics_crm/xml/entity_reference.rb', line 31 def to_hash { :logical_name => @logical_name, :id => @id, :name => @name, } end |
#to_xml(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dynamics_crm/xml/entity_reference.rb', line 13 def to_xml(={}) namespace = [:namespace] ? "#{[:namespace]}:" : '' xml = %Q{ <#{namespace}Id>#{@id}</#{namespace}Id> <#{namespace}LogicalName>#{@logical_name}</#{namespace}LogicalName> <#{namespace}Name #{@name ? '' : 'nil="true"'}>#{@name}</#{namespace}Name> } # Associate/Disassociate request requires CamelCase while others require lowerCase tag_name = [:camel_case] ? "EntityReference" : "entityReference" if [:exclude_root].nil? xml = %Q{ <#{namespace}#{tag_name}>#{xml}</#{namespace}#{tag_name}> } end return xml end |