Class: DynamicsCRM::Metadata::OneToManyRelationship

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

Overview

Represents OneToManyRelationshipMetadata XML fragment.

Direct Known Subclasses

ManyToManyRelationship

Instance Attribute Summary collapse

Attributes inherited from XmlDocument

#document

Instance Method Summary collapse

Methods inherited from XmlDocument

#method_missing, #respond_to_missing?

Constructor Details

#initialize(entity, xml_fragment) ⇒ OneToManyRelationship

Returns a new instance of OneToManyRelationship.



8
9
10
11
# File 'lib/dynamics_crm/metadata/one_to_many_relationship.rb', line 8

def initialize(entity, xml_fragment)
  super(xml_fragment)
  @entity = entity
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class DynamicsCRM::Metadata::XmlDocument

Instance Attribute Details

#entityObject (readonly)

Returns the value of attribute entity.



6
7
8
# File 'lib/dynamics_crm/metadata/one_to_many_relationship.rb', line 6

def entity
  @entity
end

Instance Method Details



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

def link_entity_fragment(attributes=[])
  from_object = self.ReferencedEntity
  from_attribute = self.ReferencedAttribute
  to_object = self.ReferencingEntity
  to_attribute = self.ReferencingAttribute

  attribute_xml = attributes.map {|a| %Q{  <attribute name="#{a}" />} }.join("\n")
%Q{
<link-entity name="#{from_object}" from="#{from_attribute}" to="#{to_attribute}" alias="#{from_object}">
#{attribute_xml}
</link-entity>
}
end