Sha256: 52db0b5f828c3b0b1d98caecf7c771da8490435211d379715edc0f0feed23325

Contents?: true

Size: 744 Bytes

Versions: 3

Compression:

Stored size: 744 Bytes

Contents

require 'date'

module OData
  class Property
    attr_reader :name
    attr_reader :nullable
    attr_reader :type

    def initialize(options = {})
      @name     = options[:name]
      @nullable = options[:nullable]
      @type     = options[:type]
    end

    def collection?
      OData::CollectionType === type
    end

    def coerce_to_type(value)
      return nil if value.nil?
      type.coerce(value)
    end

    def collection_type_match?(value)
      collection = type
      collection.valid_value?(value)
    end

    def type_match?(value)
      type.valid_value?(value) || (value.nil? && nullable)
    end

    def nullable_match?(value)
      nullable || !value.nil?
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
microsoft_graph-0.1.3 lib/odata/property.rb
microsoft_graph-0.1.1 lib/odata/property.rb
microsoft_graph-0.1.0 lib/odata/property.rb