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
Class Method Summary collapse
-
.apply(table) { ... } ⇒ void
private
Evaluate ‘block` in the context of this DSL, and apply directives to `table`.
Instance Method Summary collapse
-
#column(name, type, options = {}) ⇒ void
Define a data column on the table.
-
#compact_storage ⇒ void
Direct that this table use “compact storage”.
-
#initialize(table) ⇒ CreateTableDSL
constructor
private
A new instance of CreateTableDSL.
-
#key(name, type, clustering_order = nil) ⇒ void
Define a key column.
-
#list(name, type) ⇒ void
Define a list column on the table.
-
#map(name, key_type, value_type) ⇒ void
Define a map column on the table.
-
#partition_key(name, type) ⇒ void
Define a partition key for the table.
-
#set(name, type) ⇒ void
Define a set column on the table.
-
#with(name, value) ⇒ void
Define a storage property for the table.
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.
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`
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 = {}) ⇒ void
This method returns an undefined value.
Define a data column on the table
51 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 51 def_delegator :@table, :add_data_column, :column |
#compact_storage ⇒ void
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.
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) ⇒ void
This method returns an undefined value.
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.
45 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 45 def_delegator :@table, :add_key, :key |
#list(name, type) ⇒ void
This method returns an undefined value.
Define a list column on the table
57 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 57 def_delegator :@table, :add_list, :list |
#map(name, key_type, value_type) ⇒ void
This method returns an undefined value.
Define a map column on the table
69 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 69 def_delegator :@table, :add_map, :map |
#partition_key(name, type) ⇒ void
This method returns an undefined value.
Define a partition key for the table
39 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 39 def_delegator :@table, :add_partition_key, :partition_key |
#set(name, type) ⇒ void
This method returns an undefined value.
Define a set column on the table
63 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 63 def_delegator :@table, :add_set, :set |
#with(name, value) ⇒ void
This method returns an undefined value.
Define a storage property for the table
75 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 75 def_delegator :@table, :add_property, :with |