Class: Cequel::Type::Uuid

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

Overview

‘uuid` columns store type 1 and type 4 UUIDs. New UUID instances can be created using the Cequel.uuid method, and a value can be checked to see if it is a UUID recognized by Cequel using the Cequel.uuid? method.

See Also:

Since:

  • 1.0.0

Direct Known Subclasses

Timeuuid

Instance Method Summary collapse

Methods inherited from Base

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

Instance Method Details

#cast(value) ⇒ Object

Since:

  • 1.0.0



416
417
418
419
420
421
422
423
424
425
426
# File 'lib/cequel/type.rb', line 416

def cast(value)
  if value.is_a? Cql::Uuid then value
  elsif defined?(SimpleUUID::UUID) && value.is_a?(SimpleUUID::UUID)
    Cql::Uuid.new(value.to_i)
  elsif value.is_a?(::Integer) || value.is_a?(::String)
    Cql::Uuid.new(value)
  else
    fail ArgumentError,
         "Don't know how to cast #{value.inspect} to a UUID"
  end
end

#internal_namesObject

Since:

  • 1.0.0



412
413
414
# File 'lib/cequel/type.rb', line 412

def internal_names
  ['org.apache.cassandra.db.marshal.UUIDType']
end