class FlatKit::FieldType::BooleanType
Constants
- FALSEY_REGEX
- REGEX
- TRUTHY_REGEX
Public Class Methods
coerce(data)
click to toggle source
# File lib/flat_kit/field_type/boolean_type.rb, line 30 def self.coerce(data) case data when TrueClass true when FalseClass false when Numeric return false if data.zero? return true if data == 1 CoerceFailure when String return true if TRUTHY_REGEX.match?(data) return false if FALSEY_REGEX.match?(data) CoerceFailure end end
matches?(data)
click to toggle source
# File lib/flat_kit/field_type/boolean_type.rb, line 13 def self.matches?(data) case data when TrueClass true when FalseClass true when String REGEX.match?(data) when Integer return true if data.zero? return true if data == 1 return false else false end end
type_name()
click to toggle source
# File lib/flat_kit/field_type/boolean_type.rb, line 9 def self.type_name "boolean" end