Class: Hako::Schema::Nullable
- Inherits:
-
Object
- Object
- Hako::Schema::Nullable
- Defined in:
- lib/hako/schema/nullable.rb
Instance Method Summary collapse
-
#initialize(schema) ⇒ Nullable
constructor
A new instance of Nullable.
- #same?(x, y) ⇒ Boolean
- #valid?(object) ⇒ Boolean
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
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
10 11 12 |
# File 'lib/hako/schema/nullable.rb', line 10 def valid?(object) object.nil? || @schema.valid?(object) end |