Class: DynamicsCRM::FetchXml::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamics_crm/fetch_xml/entity.rb

Direct Known Subclasses

LinkEntity

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logical_name, options = {}) ⇒ Entity

Returns a new instance of Entity.



8
9
10
11
12
13
14
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 8

def initialize(logical_name, options={})
  # options used by LinkEntity subclass
  @logical_name = logical_name
  @attributes = []
  @link_entities = []
  @conditions = []
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 4

def attributes
  @attributes
end

#conditionsObject (readonly)

Returns the value of attribute conditions.



6
7
8
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 6

def conditions
  @conditions
end

Returns the value of attribute link_entities.



6
7
8
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 6

def link_entities
  @link_entities
end

#logical_nameObject (readonly)

Returns the value of attribute logical_name.



4
5
6
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 4

def logical_name
  @logical_name
end

#order_descObject (readonly)

Returns the value of attribute order_desc.



5
6
7
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 5

def order_desc
  @order_desc
end

#order_fieldObject (readonly)

Returns the value of attribute order_field.



5
6
7
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 5

def order_field
  @order_field
end

Instance Method Details

#add_attributes(field_names = nil) ⇒ Object



16
17
18
19
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 16

def add_attributes(field_names=nil)
  @attributes = field_names
  self
end

#add_condition(attribute, operator, value) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 33

def add_condition(attribute, operator, value)
  @conditions << {
    attribute: attribute,
    operator: operator,
    value: value
  }
  self
end

#has_conditions?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 42

def has_conditions?
  @conditions.any?
end


28
29
30
31
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 28

def link_entity(logical_name, attributes={})
  @link_entities << LinkEntity.new(logical_name, attributes)
  @link_entities.last
end

#order(field_name, descending = false) ⇒ Object

<order attribute=“productid” descending=“false” />



22
23
24
25
26
# File 'lib/dynamics_crm/fetch_xml/entity.rb', line 22

def order(field_name, descending=false)
  @order_field = field_name
  @order_desc = descending
  self
end