Class: Cequel::Schema::CreateTableDSL

Inherits:
BasicObject
Extended by:
Forwardable
Defined in:
lib/cequel/schema/create_table_dsl.rb

Overview

Implements a DSL that can be used to define a table schema

See Also:

Since:

  • 1.0.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ CreateTableDSL

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.

Returns a new instance of CreateTableDSL.

Since:

  • 1.0.0

Parameters:

  • table to apply directives to

API:

  • private



31
32
33
# File 'lib/cequel/schema/create_table_dsl.rb', line 31

def initialize(table)
  @table = table
end

Class Method Details

.apply(table) { ... } ⇒ void

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.

Evaluate block in the context of this DSL, and apply directives to table

Yields:

  • block evaluated in the context of the create table DSL

Since:

  • 1.0.0

Parameters:

  • a table

API:

  • private



21
22
23
24
# File 'lib/cequel/schema/create_table_dsl.rb', line 21

def self.apply(table, &block)
  dsl = new(table)
  dsl.instance_eval(&block)
end

Instance Method Details

#column(name, type, options = {}) ⇒ Object

Define a data column on the table

Parameters:

  • name [Symbol] name of the column

  • type [Type] type for the column

  • options [Options] options for the column

Returns:

  • void


51
# File 'lib/cequel/schema/create_table_dsl.rb', line 51

def_delegator :@table, :add_data_column, :column

#compact_storagevoid

This method returns an undefined value.

Direct that this table use “compact storage”. This is primarily useful for backwards compatibility with legacy CQL2 table schemas.

Since:

  • 1.0.0



83
84
85
# File 'lib/cequel/schema/create_table_dsl.rb', line 83

def compact_storage
  @table.compact_storage = true
end

#key(name, type, clustering_order = nil) ⇒ Object

Define a key column. If this is the first key column defined, it will be a partition key; otherwise, it will be a clustering column.

See Also:

  • #add_partition_key

Parameters:

  • name [Symbol] the name of the column

  • type [Symbol,Type] the type for the column

  • clustering_order [:asc,:desc] whether rows should be in ascending or descending order by this column. Only meaningful for clustering columns.

Returns:

  • void


45
# File 'lib/cequel/schema/create_table_dsl.rb', line 45

def_delegator :@table, :add_key, :key

#list(name, type) ⇒ Object

Define a list column on the table

See Also:

Parameters:

  • name [Symbol] name of the list

  • type [Symbol,Type] type of the list’s elements

Returns:

  • void


57
# File 'lib/cequel/schema/create_table_dsl.rb', line 57

def_delegator :@table, :add_list, :list

#map(name, key_type, value_type) ⇒ Object

Define a map column on the table

See Also:

Parameters:

  • name [Symbol] name of the set

  • key_type [Symbol,Type] type of the map’s keys

  • value_type [Symbol,Type] type of the map’s values

Returns:

  • void


69
# File 'lib/cequel/schema/create_table_dsl.rb', line 69

def_delegator :@table, :add_map, :map

#partition_key(name, type) ⇒ Object

Define a partition key for the table

Parameters:

  • name [Symbol] the name of the column

  • type [Symbol,Type] the type for the column

Returns:

  • void


39
# File 'lib/cequel/schema/create_table_dsl.rb', line 39

def_delegator :@table, :add_partition_key, :partition_key

#set(name, type) ⇒ Object

Define a set column on the table

See Also:

Parameters:

  • name [Symbol] name of the set

  • type [Symbol,Type] type of the set’s elements

Returns:

  • void


63
# File 'lib/cequel/schema/create_table_dsl.rb', line 63

def_delegator :@table, :add_set, :set

#with(name, value) ⇒ Object

Define a storage property for the table

See Also:

Parameters:

  • name [Symbol] name of the property

  • value value for the property

Returns:

  • void


75
# File 'lib/cequel/schema/create_table_dsl.rb', line 75

def_delegator :@table, :add_property, :with