Class: OdataDuty::Property::CollectionProp

Inherits:
SingleProp
  • Object
show all
Defined in:
lib/odata_duty/property/collection_prop.rb

Instance Attribute Summary

Attributes inherited from SingleProp

#calling_method, #line__defined__at, #method_name, #mutability, #name, #nullable, #raw_type, #set_type, #type

Instance Method Summary collapse

Methods inherited from SingleProp

#boolean?, #calling_method?, #computed?, #core_annotation_term, #date?, #datetime?, #enum?, #enum_members, #filter_convert, #immutable?, #initialize, #int?, #non_insertable?, #nullable?, #scalar?, #settable_on_create?, #settable_on_update?, #string?, #to_oas2, #to_value

Constructor Details

This class inherits a constructor from OdataDuty::Property::SingleProp

Instance Method Details

#collection?Boolean

Returns:

  • (Boolean)


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

def collection?
  true
end

#convert(value, context) ⇒ Object



6
7
8
9
10
# File 'lib/odata_duty/property/collection_prop.rb', line 6

def convert(value, context)
  value.map { |v| super(v, context) }
rescue NoMethodError
  raise InvalidValue, "#{value} is not an collection"
end

#to_oas2_typeObject



12
13
14
15
16
17
18
# File 'lib/odata_duty/property/collection_prop.rb', line 12

def to_oas2_type
  if scalar?
    raw_type.to_oas2(is_collection: true)
  else
    { 'type' => 'array', 'items' => { '$ref' => "#/definitions/#{raw_type.name}" } }
  end
end