Class: CassandraObject::Types::BooleanType
- Inherits:
-
BaseType
- Object
- BaseType
- CassandraObject::Types::BooleanType
show all
- Defined in:
- lib/cassandra_object/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
#options
Instance Method Summary
collapse
Methods inherited from BaseType
#default, #initialize, #wrap
Instance Method Details
#decode(str) ⇒ Object
15
16
17
|
# File 'lib/cassandra_object/types/boolean_type.rb', line 15
def decode(str)
TRUE_VALS.include?(str)
end
|
#encode(bool) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/cassandra_object/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) ? '1' : '0'
end
|