Class: CassandraObject::Types::StringType
- Inherits:
-
BaseType
- Object
- BaseType
- CassandraObject::Types::StringType
show all
- Defined in:
- lib/cassandra_object/types/string_type.rb
Instance Attribute Summary
Attributes inherited from BaseType
#options
Instance Method Summary
collapse
Methods inherited from BaseType
#default, #initialize
Instance Method Details
#decode(str) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/cassandra_object/types/string_type.rb', line 14
def decode(str)
begin
(str.frozen? ? str.dup : str).force_encoding('UTF-8') if str
rescue Exception
str.to_s
end
end
|
#encode(str) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/cassandra_object/types/string_type.rb', line 4
def encode(str)
raise ArgumentError.new("#{str.inspect} is not a String") unless str.kind_of?(String)
unless str.encoding == Encoding::UTF_8
(str.frozen? ? str.dup : str).force_encoding('UTF-8')
else
str
end
end
|
#typecast(value) ⇒ Object
22
23
24
|
# File 'lib/cassandra_object/types/string_type.rb', line 22
def typecast(value)
value.to_s
end
|