Sha256: 2edecd28fc7061e479d9fa0185522d4a16903c4f6165e6b97e958fd7b7492b95

Contents?: true

Size: 420 Bytes

Versions: 50

Compression:

Stored size: 420 Bytes

Contents

# frozen_string_literal: true

module Hako
  module Schema
    class Nullable
      def initialize(schema)
        @schema = schema
      end

      def valid?(object)
        object.nil? || @schema.valid?(object)
      end

      def same?(x, y)
        if x.nil? && y.nil?
          true
        elsif x.nil? || y.nil?
          false
        else
          @schema.same?(x, y)
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
hako-2.17.0 lib/hako/schema/nullable.rb
hako-2.16.0 lib/hako/schema/nullable.rb
hako-2.15.1 lib/hako/schema/nullable.rb
hako-2.15.0 lib/hako/schema/nullable.rb
hako-2.14.0 lib/hako/schema/nullable.rb
hako-2.13.0 lib/hako/schema/nullable.rb
hako-2.12.0 lib/hako/schema/nullable.rb
hako-2.11.1 lib/hako/schema/nullable.rb
hako-2.11.0 lib/hako/schema/nullable.rb
hako-2.10.0 lib/hako/schema/nullable.rb
hako-2.9.2 lib/hako/schema/nullable.rb
hako-2.9.1 lib/hako/schema/nullable.rb
hako-2.9.0 lib/hako/schema/nullable.rb
hako-2.8.0 lib/hako/schema/nullable.rb
hako-2.7.0 lib/hako/schema/nullable.rb
hako-2.6.2 lib/hako/schema/nullable.rb
hako-2.6.1 lib/hako/schema/nullable.rb
hako-2.6.0 lib/hako/schema/nullable.rb
hako-2.5.1 lib/hako/schema/nullable.rb
hako-2.5.0 lib/hako/schema/nullable.rb