Class: FrOData::Schema::ComplexType

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

Constructor Details

#initialize(type_definition, schema) ⇒ ComplexType

Creates a new ComplexType based on the supplied options.

Parameters:



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

#nameString

The name of the ComplexType

Returns:

  • (String)


18
19
20
# File 'lib/frodata/schema/complex_type.rb', line 18

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

#namespaceString

Returns the namespace this ComplexType belongs to.

Returns:

  • (String)


30
31
32
# File 'lib/frodata/schema/complex_type.rb', line 30

def namespace
  @namespace ||= service.namespace
end

#propertiesHash<String, FrOData::Property>

Returns this ComplexType’s properties.

Returns:



36
37
38
# File 'lib/frodata/schema/complex_type.rb', line 36

def properties
  @properties ||= collect_properties
end

#property_classClass < FrOData::Properties::Complex]

Returns the property class that implements this ‘ComplexType`.

Returns:



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

Returns a list of this ComplexType’s property names.

Returns:

  • (Array<String>)


42
43
44
# File 'lib/frodata/schema/complex_type.rb', line 42

def property_names
  @property_names ||= properties.keys
end

#typeString

Returns the namespaced type for the ComplexType.

Returns:

  • (String)


24
25
26
# File 'lib/frodata/schema/complex_type.rb', line 24

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