Class: Kafo::DataTypes::NotUndef
- Inherits:
-
Kafo::DataType
- Object
- Kafo::DataType
- Kafo::DataTypes::NotUndef
- Extended by:
- Forwardable
- Defined in:
- lib/kafo/data_types/not_undef.rb
Instance Attribute Summary collapse
-
#inner_type ⇒ Object
readonly
Returns the value of attribute inner_type.
-
#inner_value ⇒ Object
readonly
Returns the value of attribute inner_value.
Instance Method Summary collapse
-
#initialize(inner_type_or_value) ⇒ NotUndef
constructor
A new instance of NotUndef.
- #to_s ⇒ Object
- #valid?(input, errors = []) ⇒ Boolean
Methods inherited from Kafo::DataType
#condition_value, #dump_default, #multivalued?, new_from_string, parse_hash, register_type, split_arguments, #typecast, types, unregister_type
Constructor Details
#initialize(inner_type_or_value) ⇒ NotUndef
Returns a new instance of NotUndef.
10 11 12 13 14 15 16 |
# File 'lib/kafo/data_types/not_undef.rb', line 10 def initialize(inner_type_or_value) @inner_type = DataType.new_from_string(inner_type_or_value) @inner_value = nil rescue ConfigurationException @inner_type = nil @inner_value = inner_type_or_value end |
Instance Attribute Details
#inner_type ⇒ Object (readonly)
Returns the value of attribute inner_type.
8 9 10 |
# File 'lib/kafo/data_types/not_undef.rb', line 8 def inner_type @inner_type end |
#inner_value ⇒ Object (readonly)
Returns the value of attribute inner_value.
8 9 10 |
# File 'lib/kafo/data_types/not_undef.rb', line 8 def inner_value @inner_value end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/kafo/data_types/not_undef.rb', line 18 def to_s if @inner_type "#{@inner_type} but not undef" else "#{@inner_value.inspect} but not undef" end end |
#valid?(input, errors = []) ⇒ Boolean
26 27 28 29 30 31 |
# File 'lib/kafo/data_types/not_undef.rb', line 26 def valid?(input, errors = []) return false if input.nil? return true if @inner_type && @inner_type.valid?(input, errors) return true if @inner_value && @inner_value == input return false end |