Class: Cassandra::ColumnContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra/column_container.rb

Overview

This class contains all the logic needed for manipulating columns of an object.

Direct Known Subclasses

MaterializedView, Table

Defined Under Namespace

Classes: Compaction, Options

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#clustering_columnsArray<Cassandra::Column> (readonly)

Returns ordered list of column-names that make up the clustering-columns.

Returns:

  • (Array<Cassandra::Column>)

    ordered list of column-names that make up the clustering-columns.



230
231
232
# File 'lib/cassandra/column_container.rb', line 230

def clustering_columns
  @clustering_columns
end

#idCassandra::Uuid (readonly)

Returns the id of this object in Cassandra.

Returns:



222
223
224
# File 'lib/cassandra/column_container.rb', line 222

def id
  @id
end

#keyspaceCassandra::Keyspace (readonly)

Returns the keyspace that this column-container belongs to.

Returns:



224
225
226
# File 'lib/cassandra/column_container.rb', line 224

def keyspace
  @keyspace
end

#nameString (readonly)

Returns name of this column-container.

Returns:

  • (String)

    name of this column-container



220
221
222
# File 'lib/cassandra/column_container.rb', line 220

def name
  @name
end

#optionsColumnContainer::Options (readonly)

Returns collection of configuration options of this column-container.

Returns:



226
227
228
# File 'lib/cassandra/column_container.rb', line 226

def options
  @options
end

#partition_keyArray<Cassandra::Column> (readonly)

Returns ordered list of column-names that make up the partition-key.

Returns:

  • (Array<Cassandra::Column>)

    ordered list of column-names that make up the partition-key.



228
229
230
# File 'lib/cassandra/column_container.rb', line 228

def partition_key
  @partition_key
end

#primary_keyArray<Cassandra::Column> (readonly)

Note:

This composition produces a flat list, so it will not be possible for the caller to distinguish partition-key columns from clustering-columns.

Returns primary key of this column-container. It's the combination of partition_key and clustering_columns.

Returns:

  • (Array<Cassandra::Column>)

    primary key of this column-container. It's the combination of partition_key and clustering_columns.



235
236
237
# File 'lib/cassandra/column_container.rb', line 235

def primary_key
  @primary_key
end

Instance Method Details

#column(name) ⇒ Cassandra::Column?

Returns a column or nil.

Parameters:

  • name (String)

    column name

Returns:



272
273
274
# File 'lib/cassandra/column_container.rb', line 272

def column(name)
  @columns_hash[name]
end

#each_column {|column| ... } ⇒ Cassandra::ColumnContainer #each_columnArray<Cassandra::Column> Also known as: columns

Yield or enumerate each column defined in this column-container

Overloads:



282
283
284
285
286
287
288
289
# File 'lib/cassandra/column_container.rb', line 282

def each_column(&block)
  if block_given?
    @columns.each(&block)
    self
  else
    @columns
  end
end

#has_column?(name) ⇒ Boolean

Returns whether this column-container has a given column.

Parameters:

  • name (String)

    column name

Returns:

  • (Boolean)

    whether this column-container has a given column



266
267
268
# File 'lib/cassandra/column_container.rb', line 266

def has_column?(name)
  @columns_hash.key?(name)
end