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.



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

def initialize(complex_type)
  @complex_type = complex_type
end

Instance Attribute Details

#complex_typeObject (readonly)

Returns the value of attribute complex_type.



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

def complex_type
  @complex_type
end

Instance Method Details

#descriptionObject



43
44
45
# File 'lib/odata_duty/complex_type.rb', line 43

def description
  complex_type.description
end

#metadata_typeObject



47
48
49
# File 'lib/odata_duty/complex_type.rb', line 47

def 
  :complex
end

#metadata_types(visited = []) ⇒ Object

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



52
53
54
55
56
57
58
59
60
61
# File 'lib/odata_duty/complex_type.rb', line 52

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



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

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

#propertiesObject



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

def properties
  complex_type.properties
end

#property_typeObject



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

def property_type
  name
end

#scalar?Boolean

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

Returns:

  • (Boolean)


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

def scalar?; end