class FrOData::Properties::Collection
Defines the Collection
FrOData
type.
Public Class Methods
new(name, value, options = {})
click to toggle source
Overriding default constructor to avoid converting value to string. TODO: Make this the default for all property types?
Calls superclass method
FrOData::Property::new
# File lib/frodata/properties/collection.rb, line 8 def initialize(name, value, options = {}) super(name, value, options) self.value = value end
Public Instance Methods
type()
click to toggle source
# File lib/frodata/properties/collection.rb, line 37 def type "Collection(#{value_type})" end
type_class()
click to toggle source
# File lib/frodata/properties/collection.rb, line 45 def type_class FrOData::PropertyRegistry[value_type] end
url_value()
click to toggle source
# File lib/frodata/properties/collection.rb, line 33 def url_value '[' + @value.map(&:url_value).join(',') + ']' end
value()
click to toggle source
# File lib/frodata/properties/collection.rb, line 13 def value if @value.nil? nil else @value.map(&:value) end end
value=(value)
click to toggle source
# File lib/frodata/properties/collection.rb, line 21 def value=(value) if value.nil? && allows_nil? @value = nil elsif value.respond_to?(:map) @value = value.map.with_index do |element, index| type_class.new("#{name}[#{index}]", element) end else validation_error 'Value must be an array' end end
value_type()
click to toggle source
# File lib/frodata/properties/collection.rb, line 41 def value_type options[:value_type] || 'Edm.String' end