Class: Lycra::Types::Boolean
Instance Attribute Summary
Attributes inherited from Type
Class Method Summary collapse
Methods inherited from Type
#initialize, klasses, to_s, #transform, type, #type, #valid?
Constructor Details
This class inherits a constructor from Lycra::Types::Type
Class Method Details
.transform(value) ⇒ Object
90 91 92 93 94 |
# File 'lib/lycra/types.rb', line 90 def self.transform(value) return value if [true, false].include?(value) return true if value == 1 false # 0, nil end |
.valid?(value, required = false, nested = false) ⇒ Boolean
86 87 88 |
# File 'lib/lycra/types.rb', line 86 def self.valid?(value, required=false, nested=false) [true, false, 0, 1, nil].include?(value) end |