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
blockin the context of this DSL, and apply directives totable.
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.
30 31 32 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 30 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
20 21 22 23 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 20 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
50 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 50 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.
82 83 84 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 82 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.
44 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 44 def_delegator :@table, :add_key, :key |
#list(name, type) ⇒ void
This method returns an undefined value.
Define a list column on the table
56 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 56 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
68 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 68 def_delegator :@table, :add_map, :map |
#partition_key(name, type) ⇒ void
This method returns an undefined value.
Define a partition key for the table
38 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 38 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
62 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 62 def_delegator :@table, :add_set, :set |
#with(name, value) ⇒ void
This method returns an undefined value.
Define a storage property for the table
74 |
# File 'lib/cequel/schema/create_table_dsl.rb', line 74 def_delegator :@table, :add_property, :with |