Class: Definition::Types::Nil

Inherits:
Base
  • Object
show all
Defined in:
lib/definition/types/nil.rb

Instance Attribute Summary

Attributes inherited from Base

#context, #name

Instance Method Summary collapse

Methods inherited from Base

#error_renderer, #explain

Constructor Details

#initializeNil

Returns a new instance of Nil.



8
9
10
# File 'lib/definition/types/nil.rb', line 8

def initialize
  super(:nil)
end

Instance Method Details

#conform(value) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/definition/types/nil.rb', line 12

def conform(value)
  if value.nil?
    ConformResult.new(value)
  else
    ConformResult.new(value, errors: [
                        ConformError.new(self, "Did not pass test for nil")
                      ])
  end
end