Sha256: 7b40f2ec852c3891f11b0fab465bcf3458bb12eef94bd55b464ca66b1a92a7fa

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 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

1 entries across 1 versions & 1 rubygems

Version Path
microsoft_graph-0.1.2 lib/odata/property.rb