Class: OData4::ComplexType

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(type_definition, service) ⇒ self

Creates a new ComplexType based on the supplied options.

Parameters:



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

#nameString

The name of the ComplexType

Returns:

  • (String)


20
21
22
# File 'lib/odata4/complex_type.rb', line 20

def name
  @name ||= type_definition.attributes['Name'].value
end

#namespaceString

Returns the namespace this ComplexType belongs to.

Returns:

  • (String)


32
33
34
# File 'lib/odata4/complex_type.rb', line 32

def namespace
  @namespace ||= service.namespace
end

#propertiesHash<String, OData4::Property>

Returns this ComplexType’s properties.

Returns:



38
39
40
# File 'lib/odata4/complex_type.rb', line 38

def properties
  @properties ||= collect_properties
end

#property_classClass < OData4::ComplexType::Property]

Returns the property class that implements this ComplexType.

Returns:



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_namesArray<String>

Returns a list of this ComplexType’s property names.

Returns:

  • (Array<String>)


44
45
46
# File 'lib/odata4/complex_type.rb', line 44

def property_names
  @property_names ||= properties.keys
end

#typeString

Returns the namespaced type for the ComplexType.

Returns:

  • (String)


26
27
28
# File 'lib/odata4/complex_type.rb', line 26

def type
  "#{namespace}.#{name}"
end