class OData4::NavigationProperty::Proxy
Attributes
entity[R]
Public Class Methods
new(entity, nav_name)
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 4 def initialize(entity, nav_name) @entity = entity @nav_name = nav_name end
Public Instance Methods
value()
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 13 def value if link.nil? if nav_property.nav_type == :collection [] else nil end else @value ||= fetch_result end end
value=(value)
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 9 def value=(value) @value = value end
Private Instance Methods
entity_type()
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 41 def entity_type @entity_type ||= entity.name end
fetch_result()
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 53 def fetch_result raise "Invalid navigation link for #{nav_name}" unless link[:href] options = { type: nav_property.entity_type, namespace: namespace, service_name: entity.service_name } entity_set = Struct.new(:service, :entity_options) .new(entity.service, options) query = OData4::Query.new(entity_set) begin result = query.execute(link[:href]) rescue => ex raise ex unless ex.message =~ /Not Found/ result = [] end if nav_property.nav_type == :collection result else result.first end end
link()
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 45 def link entity.links[nav_name] end
namespace()
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 33 def namespace @namespace ||= service.namespace end
schema()
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 37 def schema @schema ||= service.schemas[namespace] end
service()
click to toggle source
# File lib/odata4/navigation_property/proxy.rb, line 29 def service @service ||= OData4::ServiceRegistry[entity.service_name] end