Class: ActiveColumn::Tasks::ColumnFamily
- Defined in:
- lib/active_column/tasks/column_family.rb
Constant Summary collapse
- COMPARATOR_TYPES =
{ :time => 'TimeUUIDType', :timestamp => 'TimeUUIDType', :long => 'LongType', :string => 'BytesType' }
Instance Method Summary collapse
- #clear(name) ⇒ Object
- #create(name, &block) ⇒ Object
- #drop(name) ⇒ Object
- #exists?(name) ⇒ Boolean
-
#initialize(keyspace) ⇒ ColumnFamily
constructor
A new instance of ColumnFamily.
- #rename(old_name, new_name) ⇒ Object
Constructor Details
#initialize(keyspace) ⇒ ColumnFamily
Returns a new instance of ColumnFamily.
12 13 14 15 |
# File 'lib/active_column/tasks/column_family.rb', line 12 def initialize(keyspace) raise 'Cannot operate on system keyspace' if keyspace == 'system' @keyspace = keyspace end |
Instance Method Details
#clear(name) ⇒ Object
41 42 43 |
# File 'lib/active_column/tasks/column_family.rb', line 41 def clear(name) connection.truncate!(name.to_s) end |
#create(name, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/active_column/tasks/column_family.rb', line 21 def create(name, &block) cf = Cassandra::ColumnFamily.new cf.name = name.to_s cf.keyspace = @keyspace.to_s cf.comparator_type = 'TimeUUIDType' block.call cf if block post_process_column_family(cf) connection.add_column_family(cf) end |
#drop(name) ⇒ Object
33 34 35 |
# File 'lib/active_column/tasks/column_family.rb', line 33 def drop(name) connection.drop_column_family(name.to_s) end |
#exists?(name) ⇒ Boolean
17 18 19 |
# File 'lib/active_column/tasks/column_family.rb', line 17 def exists?(name) connection.schema.cf_defs.find { |cf_def| cf_def.name == name.to_s } end |
#rename(old_name, new_name) ⇒ Object
37 38 39 |
# File 'lib/active_column/tasks/column_family.rb', line 37 def rename(old_name, new_name) connection.rename_column_family(old_name.to_s, new_name.to_s) end |