class OData4::EntityContainer

Attributes

metadata[R]

The EntityContainer's metadata

service[R]

The EntityContainer's parent service

Public Class Methods

new(service) click to toggle source

Creates a new EntityContainer @param service [OData4::Service] The entity container's parent service

# File lib/odata4/entity_container.rb, line 11
def initialize(service)
  @metadata = service.metadata.xpath('//EntityContainer').first
  @service  = service
end

Public Instance Methods

[](entity_set_name) click to toggle source

Retrieves the EntitySet associated with a specific EntityType by name

@param entity_set_name [to_s] the name of the EntitySet desired @return [OData4::EntitySet] an OData4::EntitySet to query

# File lib/odata4/entity_container.rb, line 49
def [](entity_set_name)
  xpath_query = "//EntitySet[@Name='#{entity_set_name}']"
  entity_set_node = metadata.xpath(xpath_query).first
  raise ArgumentError, "Unknown Entity Set: #{entity_set_name}" if entity_set_node.nil?
  entity_type = entity_set_node.attributes['EntityType'].value
  OData4::EntitySet.new(
    name: entity_set_name,
    namespace: namespace,
    type: entity_type,
    service_name: service.name,
    container: name
  )
end
actions() click to toggle source
# File lib/odata4/entity_container.rb, line 67
def actions
  # TODO return action imports exposed by this EntityContainer
end
entity_sets() click to toggle source

Returns a hash of EntitySet names and their respective EntityTypes. @return [Hash<String, String>]

# File lib/odata4/entity_container.rb, line 36
def entity_sets
  @entity_sets ||= metadata.xpath('//EntitySet').map do |entity|
    [
      entity.attributes['Name'].value,
      entity.attributes['EntityType'].value
    ]
  end.to_h
end
functions() click to toggle source
# File lib/odata4/entity_container.rb, line 71
def functions
  # TODO return function imports exposed by this EntityContainer
end
name() click to toggle source

Returns the EntityContainer's name. @return [String]

# File lib/odata4/entity_container.rb, line 30
def name
  @name ||= metadata.attributes['Name'].value
end
namespace() click to toggle source

Returns the EntityContainer's namespace. @return [String]

# File lib/odata4/entity_container.rb, line 24
def namespace
  @namespace ||= schema.attributes['Namespace'].value
end
schema() click to toggle source

The EntityContainer's surrounding Schema @return [Nokogiri::XML]

# File lib/odata4/entity_container.rb, line 18
def schema
  @schema ||= metadata.ancestors('Schema').first
end
singletons() click to toggle source
# File lib/odata4/entity_container.rb, line 63
def singletons
  # TODO return singletons exposed by this EntityContainer
end