class Kafo::DataTypes::Optional
Attributes
inner_type[R]
inner_value[R]
Public Class Methods
new(inner_type_or_value)
click to toggle source
# File lib/kafo/data_types/optional.rb, line 10 def initialize(inner_type_or_value) begin @inner_type = DataType.new_from_string(inner_type_or_value) rescue ConfigurationException @inner_value = inner_type_or_value end end
Public Instance Methods
to_s()
click to toggle source
# File lib/kafo/data_types/optional.rb, line 18 def to_s if @inner_type "#{@inner_type} or undef" else "#{@inner_value.inspect} or undef" end end
valid?(input, errors = [])
click to toggle source
# File lib/kafo/data_types/optional.rb, line 26 def valid?(input, errors = []) return true if input.nil? return true if @inner_type && @inner_type.valid?(input, errors) return true if @inner_value && @inner_value == input return false end