Class: Cassie::Definition

Inherits:
Object show all
Includes:
Connection, Statements::Core
Defined in:
lib/cassie/definition.rb

Overview

A concrete implementation of a functional base class used to make CQL DDL or generic queries without any DSL. Inherit from this class to create application query classes.

  • The Cassandra connection is provided and managed by Connection

  • Generic statement functionality is provided by Statements::Core

  • Defining the statement and options is up the subclass’s responsibility (e.g. no DSL is provided)

See the README for information on usage and examples.

Examples:

Inserting a record into a Table

class CreateKeyspaceQuery < Cassie::Definition
  attr_accessor :name

  self.prepare = false

  def statement
    cql = %(
      CREATE KEYSPACE #{name}
      WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
      AND durable_writes = true;
     )
  end
end

CreateKeyspaceQuery.new(name: "my keyspace").excecute
#=> true

Instance Attribute Summary

Attributes included from Statements::Execution::ClassMethods

#result_class

Attributes included from Statements::Statement

#cql, #params

Method Summary

Methods included from Statements::Core

#initialize

Methods included from Statements::Execution::ClassMethods

#inherited

Methods included from Statements::Execution

#execute, #execute!, #execution_options

Methods included from Statements::Execution::Instrumentation

#execute

Methods included from Statements::Execution::PartitionLinking

#build_partition_linker, #execute, #partition_linker?

Methods included from Statements::Execution::Callbacks

#execute

Methods included from Statements::Execution::Consistency

#consistency

Methods included from Statements::Statement

#logger, #statement, #table, #to_cql

Methods included from Statements::Statement::Preparation::ClassMethods

#prepare, #prepare=, #prepare?

Methods included from Statements::Statement::Idempotency::ClassMethods

#idempotent, #idempotent=, #idempotent?, #non_idempotent

Methods included from Statements::Statement::Idempotency

#idempotent, #idempotent?

Methods included from Statements::Statement::TypeHinting::ClassMethods

#type_hints, #type_hints=

Methods included from Statements::Statement::TypeHinting

#type_hints

Methods included from Statements::Statement::Preparation

cache, init_cache, #statement

Methods included from Connection

#keyspace, #session

Methods included from Connection::ClassMethods

#keyspace, #keyspace=