Class: Superstore::Types::BooleanType
- Inherits:
-
BaseType
- Object
- BaseType
- Superstore::Types::BooleanType
show all
- Defined in:
- lib/superstore/types/boolean_type.rb
Constant Summary
collapse
- TRUE_VALS =
[true, 'true', '1']
- FALSE_VALS =
[false, 'false', '0', '', nil]
- VALID_VALS =
TRUE_VALS + FALSE_VALS
Instance Attribute Summary
Attributes inherited from BaseType
#model, #options
Instance Method Summary
collapse
Methods inherited from BaseType
#initialize, #typecast
Instance Method Details
#decode(str) ⇒ Object
16
17
18
|
# File 'lib/superstore/types/boolean_type.rb', line 16
def decode(str)
TRUE_VALS.include?(str)
end
|
#encode(bool) ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/superstore/types/boolean_type.rb', line 8
def encode(bool)
unless VALID_VALS.include?(bool)
raise ArgumentError.new("#{bool.inspect} is not a Boolean")
end
TRUE_VALS.include?(bool)
end
|