Class: CassandraObject::Types::StringType

Inherits:
BaseType
  • Object
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

#decode, #default, #initialize

Constructor Details

This class inherits a constructor from CassandraObject::Types::BaseType

Instance Method Details

#encode(str) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
# 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)
  str.dup
end

#wrap(record, name, value) ⇒ Object



9
10
11
12
# File 'lib/cassandra_object/types/string_type.rb', line 9

def wrap(record, name, value)
  value = value.to_s
  (value.frozen? ? value.dup : value).force_encoding('UTF-8')
end