class DynamicsCRM::XML::EntityReference
Attributes
id[RW]
logical_name[RW]
name[RW]
namespace[RW]
Public Class Methods
from_xml(xml_document)
click to toggle source
# 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
new(logical_name, id)
click to toggle source
# 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
Public Instance Methods
to_hash()
click to toggle source
# 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={})
click to toggle source
# File lib/dynamics_crm/xml/entity_reference.rb, line 13 def to_xml(options={}) namespace = options[:namespace] ? "#{options[: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 = options[:camel_case] ? "EntityReference" : "entityReference" if options[:exclude_root].nil? xml = %Q{ <#{namespace}#{tag_name}>#{xml}</#{namespace}#{tag_name}> } end return xml end