Class: OdataDuty::ComplexType::Metadata

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

Direct Known Subclasses

EntityType::Metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(complex_type) ⇒ Metadata

Returns a new instance of Metadata.



22
23
24
# File 'lib/odata_duty/complex_type.rb', line 22

def initialize(complex_type)
  @complex_type = complex_type
end

Instance Attribute Details

#complex_typeObject (readonly)

Returns the value of attribute complex_type.



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

def complex_type
  @complex_type
end

Instance Method Details

#metadata_typeObject



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

def 
  :complex
end

#metadata_types(visited = []) ⇒ Object

callers uniq the result, so duplicates from repeated property types are fine



43
44
45
46
47
48
49
50
51
52
# File 'lib/odata_duty/complex_type.rb', line 43

def (visited = [])
  return [] if visited.include?(complex_type)

  visited << complex_type
  raw_types = properties.map(&:raw_type)
  nested = raw_types.grep(Metadata).flat_map { |m| m.(visited) }
  [complex_type] +
    nested +
    raw_types.grep(EnumType::Metadata).map(&:enum_type)
end

#nameObject



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

def name
  complex_type.to_s.split('::').last.sub(/ComplexType\z/, '').sub(/Complex\z/, '')
end

#propertiesObject



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

def properties
  complex_type.properties
end

#property_typeObject



34
35
36
# File 'lib/odata_duty/complex_type.rb', line 34

def property_type
  name
end

#scalar?Boolean

nil (falsy) rather than false: callers only consume truthiness

Returns:

  • (Boolean)


55
# File 'lib/odata_duty/complex_type.rb', line 55

def scalar?; end