Class: FrOData::EntityContainer
- Inherits:
-
Object
- Object
- FrOData::EntityContainer
- Defined in:
- lib/frodata/entity_container.rb
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
The EntityContainer’s metadata.
-
#service ⇒ Object
readonly
The EntityContainer’s parent service.
Instance Method Summary collapse
-
#[](entity_set_name) ⇒ FrOData::EntitySet
Retrieves the EntitySet associated with a specific EntityType by name.
- #actions ⇒ Object
-
#entity_sets ⇒ Hash<String, String>
Returns a hash of EntitySet names and their respective EntityTypes.
- #functions ⇒ Object
-
#initialize(service) ⇒ EntityContainer
constructor
Creates a new EntityContainer.
-
#name ⇒ String
Returns the EntityContainer’s name.
-
#namespace ⇒ String
Returns the EntityContainer’s namespace.
-
#schema ⇒ Nokogiri::XML
The EntityContainer’s surrounding Schema.
- #singletons ⇒ Object
Constructor Details
#initialize(service) ⇒ EntityContainer
Creates a new EntityContainer
11 12 13 14 |
# File 'lib/frodata/entity_container.rb', line 11 def initialize(service) @metadata = service..xpath('//EntityContainer').first @service = service end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
The EntityContainer’s metadata
7 8 9 |
# File 'lib/frodata/entity_container.rb', line 7 def @metadata end |
#service ⇒ Object (readonly)
The EntityContainer’s parent service
5 6 7 |
# File 'lib/frodata/entity_container.rb', line 5 def service @service end |
Instance Method Details
#[](entity_set_name) ⇒ FrOData::EntitySet
Retrieves the EntitySet associated with a specific EntityType by name
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/frodata/entity_container.rb', line 49 def [](entity_set_name) xpath_query = "//EntitySet[@Name='#{entity_set_name}']" entity_set_node = .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 FrOData::EntitySet.new( name: entity_set_name, namespace: namespace, type: entity_type, service_name: service.name, container: name ) end |
#actions ⇒ Object
67 68 69 |
# File 'lib/frodata/entity_container.rb', line 67 def actions # TODO return action imports exposed by this EntityContainer end |
#entity_sets ⇒ Hash<String, String>
Returns a hash of EntitySet names and their respective EntityTypes.
36 37 38 39 40 41 42 43 |
# File 'lib/frodata/entity_container.rb', line 36 def entity_sets @entity_sets ||= .xpath('//EntitySet').map do |entity| [ entity.attributes['Name'].value, entity.attributes['EntityType'].value ] end.to_h end |
#functions ⇒ Object
71 72 73 |
# File 'lib/frodata/entity_container.rb', line 71 def functions # TODO return function imports exposed by this EntityContainer end |
#name ⇒ String
Returns the EntityContainer’s name.
30 31 32 |
# File 'lib/frodata/entity_container.rb', line 30 def name @name ||= .attributes['Name'].value end |
#namespace ⇒ String
Returns the EntityContainer’s namespace.
24 25 26 |
# File 'lib/frodata/entity_container.rb', line 24 def namespace @namespace ||= schema.attributes['Namespace'].value end |
#schema ⇒ Nokogiri::XML
The EntityContainer’s surrounding Schema
18 19 20 |
# File 'lib/frodata/entity_container.rb', line 18 def schema @schema ||= .ancestors('Schema').first end |
#singletons ⇒ Object
63 64 65 |
# File 'lib/frodata/entity_container.rb', line 63 def singletons # TODO return singletons exposed by this EntityContainer end |