class FrOData::Schema::ComplexType
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.
Public Class Methods
Creates a new ComplexType
based on the supplied options. @param type_xml [Nokogiri::XML::Element] @param service [FrOData::Service]
# File lib/frodata/schema/complex_type.rb, line 11 def initialize(type_definition, schema) @type_definition = type_definition @schema = schema end
Public Instance Methods
The name of the ComplexType
@return [String]
# File lib/frodata/schema/complex_type.rb, line 18 def name @name ||= type_definition.attributes['Name'].value end
Returns the namespace this ComplexType
belongs to. @return [String]
# File lib/frodata/schema/complex_type.rb, line 30 def namespace @namespace ||= service.namespace end
Returns this ComplexType's properties. @return [Hash<String, FrOData::Property>]
# File lib/frodata/schema/complex_type.rb, line 36 def properties @properties ||= collect_properties end
Returns the property class that implements this `ComplexType`. @return [Class < FrOData::Properties::Complex]
# 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
Returns a list of this ComplexType's property names. @return [Array<String>]
# File lib/frodata/schema/complex_type.rb, line 42 def property_names @property_names ||= properties.keys end
Returns the namespaced type for the ComplexType
. @return [String]
# File lib/frodata/schema/complex_type.rb, line 24 def type "#{namespace}.#{name}" end
Private Instance Methods
# File lib/frodata/schema/complex_type.rb, line 71 def collect_properties Hash[type_definition.xpath('./Property').map do |property_xml| property_name, property = schema.send(:process_property_from_xml, property_xml) [property_name, property] end] end
# File lib/frodata/schema/complex_type.rb, line 59 def schema @schema end
# File lib/frodata/schema/complex_type.rb, line 63 def service @schema.service end
# File lib/frodata/schema/complex_type.rb, line 67 def type_definition @type_definition end