Module: Cequel::Record::Schema::ClassMethods

Extended by:
Forwardable
Defined in:
lib/cequel/record/schema.rb

Overview

Methods available on Cequel::Record class singletons to introspect and modify the schema defined in the database

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clustering_columnsArray<ClusteringColumn> (readonly)



60
61
62
63
# File 'lib/cequel/record/schema.rb', line 60

def_delegators :table_schema, :columns, :key_columns,
:key_column_names, :partition_key_columns,
:partition_key_column_names, :clustering_columns,
:compact_storage?

#columnsArray<Column> (readonly)



60
61
62
63
# File 'lib/cequel/record/schema.rb', line 60

def_delegators :table_schema, :columns, :key_columns,
:key_column_names, :partition_key_columns,
:partition_key_column_names, :clustering_columns,
:compact_storage?

#key_column_namesArray<Symbol> (readonly)



60
61
62
63
# File 'lib/cequel/record/schema.rb', line 60

def_delegators :table_schema, :columns, :key_columns,
:key_column_names, :partition_key_columns,
:partition_key_column_names, :clustering_columns,
:compact_storage?

#key_columnsArray<Column> (readonly)



60
61
62
63
# File 'lib/cequel/record/schema.rb', line 60

def_delegators :table_schema, :columns, :key_columns,
:key_column_names, :partition_key_columns,
:partition_key_column_names, :clustering_columns,
:compact_storage?

#partition_key_column_namesArray<Symbol> (readonly)



60
61
62
63
# File 'lib/cequel/record/schema.rb', line 60

def_delegators :table_schema, :columns, :key_columns,
:key_column_names, :partition_key_columns,
:partition_key_column_names, :clustering_columns,
:compact_storage?

#partition_key_columnsArray<PartitionKey> (readonly)



60
61
62
63
# File 'lib/cequel/record/schema.rb', line 60

def_delegators :table_schema, :columns, :key_columns,
:key_column_names, :partition_key_columns,
:partition_key_column_names, :clustering_columns,
:compact_storage?

Instance Method Details

#compact_storage?Boolean



60
61
62
63
# File 'lib/cequel/record/schema.rb', line 60

def_delegators :table_schema, :columns, :key_columns,
:key_column_names, :partition_key_columns,
:partition_key_column_names, :clustering_columns,
:compact_storage?

#read_schemaSchema::Table

Read the current state of this record’s table in Cassandra from the database.

Since:

  • 1.0.0



91
92
93
# File 'lib/cequel/record/schema.rb', line 91

def read_schema
  connection.schema.read_table(table_name)
end

#reflect_on_column(name) ⇒ Column



68
# File 'lib/cequel/record/schema.rb', line 68

def_delegator :table_schema, :column, :reflect_on_column

#synchronize_schemavoid

This method returns an undefined value.

Read the current schema assigned to this record’s table from Cassandra, and make any necessary modifications (including creating the table for the first time) so that it matches the schema defined in the record definition

Since:

  • 1.0.0



79
80
81
82
# File 'lib/cequel/record/schema.rb', line 79

def synchronize_schema
  Cequel::Schema::TableSynchronizer
    .apply(connection, read_schema, table_schema)
end

#table_schemaSchema::Table

Returns the schema as defined by the columns specified in the class definition.

Since:

  • 1.0.0



99
100
101
# File 'lib/cequel/record/schema.rb', line 99

def table_schema
  @table_schema ||= Cequel::Schema::Table.new(table_name)
end