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



437
438
439
440
441
442
443
444
445
446
447
# File 'lib/cequel/type.rb', line 437

def cast(value)
  if value.is_a? Cassandra::Uuid then value
  elsif defined?(SimpleUUID::UUID) && value.is_a?(SimpleUUID::UUID)
    Cassandra::Uuid.new(value.to_i)
  elsif value.is_a?(::Integer) || value.is_a?(::String)
    Cassandra::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



433
434
435
# File 'lib/cequel/type.rb', line 433

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