Class: Hako::Schema::Nullable

Inherits:
Object
  • Object
show all
Defined in:
lib/hako/schema/nullable.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ Nullable

Returns a new instance of Nullable.



6
7
8
# File 'lib/hako/schema/nullable.rb', line 6

def initialize(schema)
  @schema = schema
end

Instance Method Details

#same?(x, y) ⇒ Boolean

Returns:



14
15
16
17
18
19
20
21
22
# File 'lib/hako/schema/nullable.rb', line 14

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

#valid?(object) ⇒ Boolean

Returns:



10
11
12
# File 'lib/hako/schema/nullable.rb', line 10

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