Class: FrOData::Schema::ComplexType
- Inherits:
-
Object
- Object
- FrOData::Schema::ComplexType
- Defined in:
- lib/frodata/schema/complex_type.rb
Overview
ComplexTypes are used in FrOData 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.
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, FrOData::Property>
Returns this ComplexType’s properties.
-
#property_class ⇒ Class < FrOData::Properties::Complex]
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.
11 12 13 14 |
# File 'lib/frodata/schema/complex_type.rb', line 11 def initialize(type_definition, schema) @type_definition = type_definition @schema = schema end |
Instance Method Details
#name ⇒ String
The name of the ComplexType
18 19 20 |
# File 'lib/frodata/schema/complex_type.rb', line 18 def name @name ||= type_definition.attributes['Name'].value end |
#namespace ⇒ String
Returns the namespace this ComplexType belongs to.
30 31 32 |
# File 'lib/frodata/schema/complex_type.rb', line 30 def namespace @namespace ||= service.namespace end |
#properties ⇒ Hash<String, FrOData::Property>
Returns this ComplexType’s properties.
36 37 38 |
# File 'lib/frodata/schema/complex_type.rb', line 36 def properties @properties ||= collect_properties end |
#property_class ⇒ Class < FrOData::Properties::Complex]
Returns the property class that implements this ‘ComplexType`.
48 49 50 51 52 53 54 55 |
# File 'lib/frodata/schema/complex_type.rb', line 48 def property_class @property_class ||= lambda { |type, complex_type| klass = Class.new ::FrOData::Properties::Complex 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.
42 43 44 |
# File 'lib/frodata/schema/complex_type.rb', line 42 def property_names @property_names ||= properties.keys end |
#type ⇒ String
Returns the namespaced type for the ComplexType.
24 25 26 |
# File 'lib/frodata/schema/complex_type.rb', line 24 def type "#{namespace}.#{name}" end |