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, schema) ⇒ ComplexType
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, schema) ⇒ ComplexType
Creates a new ComplexType based on the supplied options.
12 13 14 15 |
# File 'lib/odata4/complex_type.rb', line 12 def initialize(type_definition, schema) @type_definition = type_definition @schema = schema end |
Instance Method Details
#name ⇒ String
The name of the ComplexType
19 20 21 |
# File 'lib/odata4/complex_type.rb', line 19 def name @name ||= type_definition.attributes['Name'].value end |
#namespace ⇒ String
Returns the namespace this ComplexType belongs to.
31 32 33 |
# File 'lib/odata4/complex_type.rb', line 31 def namespace @namespace ||= service.namespace end |
#properties ⇒ Hash<String, OData4::Property>
Returns this ComplexType’s properties.
37 38 39 |
# File 'lib/odata4/complex_type.rb', line 37 def properties @properties ||= collect_properties end |
#property_class ⇒ Class < OData4::ComplexType::Property]
Returns the property class that implements this ‘ComplexType`.
49 50 51 52 53 54 55 56 |
# File 'lib/odata4/complex_type.rb', line 49 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.
43 44 45 |
# File 'lib/odata4/complex_type.rb', line 43 def property_names @property_names ||= properties.keys end |
#type ⇒ String
Returns the namespaced type for the ComplexType.
25 26 27 |
# File 'lib/odata4/complex_type.rb', line 25 def type "#{namespace}.#{name}" end |