Class: FrOData::NavigationProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/frodata/navigation_property.rb,
lib/frodata/navigation_property/proxy.rb

Defined Under Namespace

Classes: Proxy

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ NavigationProperty

Returns a new instance of NavigationProperty.



7
8
9
10
11
12
# File 'lib/frodata/navigation_property.rb', line 7

def initialize(options)
  @name     = options[:name] or raise ArgumentError, 'Name is required'
  @type     = options[:type] or raise ArgumentError, 'Type is required'
  @nullable = options[:nullable] || true
  @partner  = options[:partner]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/frodata/navigation_property.rb', line 5

def name
  @name
end

#nullableObject (readonly)

Returns the value of attribute nullable.



5
6
7
# File 'lib/frodata/navigation_property.rb', line 5

def nullable
  @nullable
end

#partnerObject (readonly)

Returns the value of attribute partner.



5
6
7
# File 'lib/frodata/navigation_property.rb', line 5

def partner
  @partner
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/frodata/navigation_property.rb', line 5

def type
  @type
end

Class Method Details

.build(nav_property_xml) ⇒ Object



22
23
24
25
26
27
# File 'lib/frodata/navigation_property.rb', line 22

def self.build(nav_property_xml)
  options = nav_property_xml.attributes.map do |name, attr|
    [name.downcase.to_sym, attr.value]
  end.to_h
  new(options)
end

Instance Method Details

#entity_typeObject



18
19
20
# File 'lib/frodata/navigation_property.rb', line 18

def entity_type
  @entity_type ||= type.split(/[()]/).last
end


14
15
16
# File 'lib/frodata/navigation_property.rb', line 14

def nav_type
  @nav_type ||= type =~ /^Collection/ ? :collection : :entity
end