Class: OData4::ComplexType
- Inherits:
-
Object
- Object
- OData4::ComplexType
- Defined in:
- lib/odata4/complex_type.rb,
lib/odata4/complex_type/property.rb
Overview
ComplexTypes are used in OData4 to either encapsulate richer data types for use as Entity properties. ComplexTypes are composed of properties the same way that Entities are and, so, the interface for working with the various properties of a ComplexType mimics that of Entities.
Defined Under Namespace
Classes: Property
Instance Method Summary collapse
-
#initialize(type_definition, service) ⇒ self
constructor
Creates a new ComplexType based on the supplied options.
-
#name ⇒ String
The name of the ComplexType.
-
#namespace ⇒ String
Returns the namespace this ComplexType belongs to.
-
#properties ⇒ Hash<String, OData4::Property>
Returns this ComplexType’s properties.
-
#property_class ⇒ Class < OData4::ComplexType::Property]
Returns the property class that implements this
ComplexType. -
#property_names ⇒ Array<String>
Returns a list of this ComplexType’s property names.
-
#type ⇒ String
Returns the namespaced type for the ComplexType.
Constructor Details
#initialize(type_definition, service) ⇒ self
Creates a new ComplexType based on the supplied options.
13 14 15 16 |
# File 'lib/odata4/complex_type.rb', line 13 def initialize(type_definition, service) @type_definition = type_definition @service = service end |
Instance Method Details
#name ⇒ String
The name of the ComplexType
20 21 22 |
# File 'lib/odata4/complex_type.rb', line 20 def name @name ||= type_definition.attributes['Name'].value end |
#namespace ⇒ String
Returns the namespace this ComplexType belongs to.
32 33 34 |
# File 'lib/odata4/complex_type.rb', line 32 def namespace @namespace ||= service.namespace end |
#properties ⇒ Hash<String, OData4::Property>
Returns this ComplexType’s properties.
38 39 40 |
# File 'lib/odata4/complex_type.rb', line 38 def properties @properties ||= collect_properties end |
#property_class ⇒ Class < OData4::ComplexType::Property]
Returns the property class that implements this ComplexType.
50 51 52 53 54 55 56 57 |
# File 'lib/odata4/complex_type.rb', line 50 def property_class @property_class ||= lambda { |type, complex_type| klass = Class.new ::OData4::ComplexType::Property klass.send(:define_method, :type) { type } klass.send(:define_method, :complex_type) { complex_type } klass }.call(type, self) end |
#property_names ⇒ Array<String>
Returns a list of this ComplexType’s property names.
44 45 46 |
# File 'lib/odata4/complex_type.rb', line 44 def property_names @property_names ||= properties.keys end |
#type ⇒ String
Returns the namespaced type for the ComplexType.
26 27 28 |
# File 'lib/odata4/complex_type.rb', line 26 def type "#{namespace}.#{name}" end |