Class: FlatKit::FieldType::NullType
Constant Summary
collapse
- REGEX =
Regexp.union(/\A(null|nil)\Z/i, /\A\\N\Z/)
CoerceFailure
Class Method Summary
collapse
best_guess, candidate_types, weight
#children, #find_child, #find_children, #inherited
Class Method Details
.coerce(data) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/flat_kit/field_type/null_type.rb', line 22
def self.coerce(data)
case data
when nil
data
when String
return nil if REGEX.match?(data)
CoerceFailure
else
CoerceFailure
end
end
|
.matches?(data) ⇒ Boolean
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/flat_kit/field_type/null_type.rb', line 11
def self.matches?(data)
case data
when nil
true
when String
REGEX.match?(data)
else
false
end
end
|
.type_name ⇒ Object
7
8
9
|
# File 'lib/flat_kit/field_type/null_type.rb', line 7
def self.type_name
"null"
end
|