Module: Cql::Model

Defined in:
lib/cql/model.rb,
lib/cql/model.rb

Defined Under Namespace

Classes: MissingKey, SyntaxError

Constant Summary collapse

Uuid =

Type aliases for use with the property-declaration DSL.

Cql::Uuid
UUID =
Uuid
Boolean =

Type alias for use with the property-declaration DSL.

TrueClass

Class Method Summary collapse

Class Method Details

.cql_client(new_client = nil) ⇒ Cql::Client

Get or set the “master” client connection shared by every model that doesn’t bother to set its own. Defaults to a localhost connection with no default keyspace; every query must be wrapped in a “using_keyspace” method call.

Parameters:

  • new_client (optional, Cql::Client) (defaults to: nil)

    the new client to set

Returns:

  • (Cql::Client)

    the current client



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cql/model.rb', line 37

def self.cql_client(new_client=nil)
  if new_client
    @@cql_model_mutex.synchronize do
      @@cql_client = new_client
    end
  else
    @@cql_client ||= Cql::Client.new
    @@cql_client.start! unless @@cql_client.connected?
  end

  @@cql_client
end

.included(klass) ⇒ Object



26
27
28
29
# File 'lib/cql/model.rb', line 26

def self.included(klass)
  klass.__send__(:extend, Cql::Model::ClassMethods)
  klass.__send__(:include, Cql::Model::InstanceMethods)
end