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



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

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



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

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



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

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