Class: OdataDuty::ComplexType

Inherits:
Object
  • Object
show all
Defined in:
lib/odata_duty/complex_type.rb

Direct Known Subclasses

EntityType, SchemaBuilder::EntityType

Defined Under Namespace

Classes: Metadata

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, context) ⇒ ComplexType

Returns a new instance of ComplexType.



74
75
76
77
# File 'lib/odata_duty/complex_type.rb', line 74

def initialize(object, context)
  @object = object
  @od_context = context
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



71
72
73
# File 'lib/odata_duty/complex_type.rb', line 71

def object
  @object
end

#od_contextObject (readonly)

Returns the value of attribute od_context.



72
73
74
# File 'lib/odata_duty/complex_type.rb', line 72

def od_context
  @od_context
end

Class Method Details

.__metadataObject



67
68
69
# File 'lib/odata_duty/complex_type.rb', line 67

def self.
  Metadata.new(self)
end

.description(text = nil) ⇒ Object



5
6
7
8
# File 'lib/odata_duty/complex_type.rb', line 5

def self.description(text = nil)
  @description = Property.resolve_description(.name, text) unless text.nil?
  @description
end

.propertiesObject



10
11
12
# File 'lib/odata_duty/complex_type.rb', line 10

def self.properties
  @properties ||= []
end

.property(name, *args, **kwargs) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/odata_duty/complex_type.rb', line 14

def self.property(name, *args, **kwargs)
  if properties.any? { |p| p.name == name.to_sym }
    raise PropertyAlreadyDefinedError, "#{name} is already defined"
  end

  Property.new(name, *args, **kwargs).tap do |property|
    properties << property
  end
end