Class: Cequel::Schema::TableWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/cequel/schema/table_writer.rb

Overview

Creates a new table schema in the database

Since:

  • 1.0.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keyspace, table) ⇒ TableWriter

Returns a new instance of TableWriter.

Parameters:

  • keyspace (Keyspace)

    keyspace in which to create the table

  • table (Table)

    object representation of table schema

Since:

  • 1.0.0



23
24
25
# File 'lib/cequel/schema/table_writer.rb', line 23

def initialize(keyspace, table)
  @keyspace, @table = keyspace, table
end

Class Method Details

.apply(keyspace, table) ⇒ void

This method returns an undefined value.

Creates a new table schema in the database given an object representation of the schema to create

Parameters:

  • keyspace (Keyspace)

    keyspace in which to create the table

  • table (Table)

    object representation of table schema

Since:

  • 1.0.0



14
15
16
# File 'lib/cequel/schema/table_writer.rb', line 14

def self.apply(keyspace, table)
  new(keyspace, table).apply
end

Instance Method Details

#applyvoid

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Create the table in the keyspace

Since:

  • 1.0.0



35
36
37
38
# File 'lib/cequel/schema/table_writer.rb', line 35

def apply
  keyspace.execute(create_statement)
  index_statements.each { |statement| keyspace.execute(statement) }
end