Class: Cequel::Type::String Abstract

Inherits:
Base
  • Object
show all
Defined in:
lib/cequel/type.rb

Overview

This class is abstract.

Subclasses must implement ‘#encoding`, which returns the name of the Ruby encoding corresponding to the character encoding used for values of this type

Abstract superclass for types that represent character data

Since:

  • 1.0.0

Direct Known Subclasses

Ascii, Blob, Text

Instance Method Summary collapse

Methods inherited from Base

#compatible_types, #cql_aliases, #cql_name, #internal_name, #internal_names, #to_s

Instance Method Details

#cast(value) ⇒ Object

Since:

  • 1.0.0



189
190
191
192
# File 'lib/cequel/type.rb', line 189

def cast(value)
  str = String(value)
  str.encoding.name == encoding ? str : str.dup.force_encoding(encoding)
end