Class: Rtype::Behavior::Nilable

Inherits:
Base show all
Defined in:
lib/rtype/behavior/nilable.rb

Instance Method Summary collapse

Methods inherited from Base

[]

Constructor Details

#initialize(type) ⇒ Nilable

Returns a new instance of Nilable.



4
5
6
# File 'lib/rtype/behavior/nilable.rb', line 4

def initialize(type)
	@type = type
end

Instance Method Details

#error_message(value) ⇒ Object



12
13
14
# File 'lib/rtype/behavior/nilable.rb', line 12

def error_message(value)
	Rtype::type_error_message(@type, value) + "\nOR " + Rtype::type_error_message(nil, value)
end

#valid?(value) ⇒ Boolean

Returns:



8
9
10
# File 'lib/rtype/behavior/nilable.rb', line 8

def valid?(value)
	value.nil? || Rtype::valid?(@type, value)
end