Class: CassandraModel::TableRedux
- Inherits:
-
Object
- Object
- CassandraModel::TableRedux
- Extended by:
- Forwardable
- Includes:
- TableDebug
- Defined in:
- lib/cassandra_model/table_redux.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #allow_truncation! ⇒ Object
- #clustering_columns ⇒ Object
- #columns ⇒ Object
- #connection ⇒ Object
-
#in_context(time) {|_self| ... } ⇒ Object
noinspection RubyUnusedLocalVariable.
-
#initialize(connection_name = nil, table_name) ⇒ TableRedux
constructor
A new instance of TableRedux.
- #partition_key ⇒ Object
- #primary_key ⇒ Object
- #reset_local_schema! ⇒ Object
- #truncate! ⇒ Object
Methods included from TableDebug
Constructor Details
#initialize(connection_name = nil, table_name) ⇒ TableRedux
8 9 10 11 |
# File 'lib/cassandra_model/table_redux.rb', line 8 def initialize(connection_name = nil, table_name) @name = table_name.to_s @connection_name = connection_name end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/cassandra_model/table_redux.rb', line 6 def name @name end |
Instance Method Details
#allow_truncation! ⇒ Object
22 23 24 |
# File 'lib/cassandra_model/table_redux.rb', line 22 def allow_truncation! @allow_truncation = true end |
#clustering_columns ⇒ Object
41 42 43 |
# File 'lib/cassandra_model/table_redux.rb', line 41 def clustering_columns @clustering_columns ||= table.send(:clustering_columns).map { |column| column.name.to_sym } end |
#columns ⇒ Object
49 50 51 |
# File 'lib/cassandra_model/table_redux.rb', line 49 def columns @columns ||= table.columns.map { |column| column.name.to_sym } end |
#connection ⇒ Object
18 19 20 |
# File 'lib/cassandra_model/table_redux.rb', line 18 def connection ConnectionCache[@connection_name] end |
#in_context(time) {|_self| ... } ⇒ Object
noinspection RubyUnusedLocalVariable
14 15 16 |
# File 'lib/cassandra_model/table_redux.rb', line 14 def in_context(time) yield self end |
#partition_key ⇒ Object
37 38 39 |
# File 'lib/cassandra_model/table_redux.rb', line 37 def partition_key @partition_key ||= table.send(:partition_key).map { |column| column.name.to_sym } end |
#primary_key ⇒ Object
45 46 47 |
# File 'lib/cassandra_model/table_redux.rb', line 45 def primary_key partition_key + clustering_columns end |
#reset_local_schema! ⇒ Object
31 32 33 34 35 |
# File 'lib/cassandra_model/table_redux.rb', line 31 def reset_local_schema! @partition_key = nil @clustering_columns = nil @columns = nil end |
#truncate! ⇒ Object
26 27 28 29 |
# File 'lib/cassandra_model/table_redux.rb', line 26 def truncate! raise "Truncation not enabled for table '#{name}'" unless @allow_truncation connection.session.execute("TRUNCATE #{name}") end |