Class: CassandraModel::TableRedux
- Inherits:
-
Object
- Object
- CassandraModel::TableRedux
- Extended by:
- Forwardable
- 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
Constructor Details
#initialize(connection_name = nil, table_name) ⇒ TableRedux
Returns a new instance of TableRedux.
7 8 9 10 |
# File 'lib/cassandra_model/table_redux.rb', line 7 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.
5 6 7 |
# File 'lib/cassandra_model/table_redux.rb', line 5 def name @name end |
Instance Method Details
#allow_truncation! ⇒ Object
21 22 23 |
# File 'lib/cassandra_model/table_redux.rb', line 21 def allow_truncation! @allow_truncation = true end |
#clustering_columns ⇒ Object
40 41 42 |
# File 'lib/cassandra_model/table_redux.rb', line 40 def clustering_columns @clustering_columns ||= table.send(:clustering_columns).map { |column| column.name.to_sym } end |
#columns ⇒ Object
48 49 50 |
# File 'lib/cassandra_model/table_redux.rb', line 48 def columns @columns ||= table.columns.map { |column| column.name.to_sym } end |
#connection ⇒ Object
17 18 19 |
# File 'lib/cassandra_model/table_redux.rb', line 17 def connection ConnectionCache[@connection_name] end |
#in_context(time) {|_self| ... } ⇒ Object
noinspection RubyUnusedLocalVariable
13 14 15 |
# File 'lib/cassandra_model/table_redux.rb', line 13 def in_context(time) yield self end |
#partition_key ⇒ Object
36 37 38 |
# File 'lib/cassandra_model/table_redux.rb', line 36 def partition_key @partition_key ||= table.send(:partition_key).map { |column| column.name.to_sym } end |
#primary_key ⇒ Object
44 45 46 |
# File 'lib/cassandra_model/table_redux.rb', line 44 def primary_key partition_key + clustering_columns end |
#reset_local_schema! ⇒ Object
30 31 32 33 34 |
# File 'lib/cassandra_model/table_redux.rb', line 30 def reset_local_schema! @partition_key = nil @clustering_columns = nil @columns = nil end |
#truncate! ⇒ Object
25 26 27 28 |
# File 'lib/cassandra_model/table_redux.rb', line 25 def truncate! raise "Truncation not enabled for table '#{name}'" unless @allow_truncation connection.session.execute("TRUNCATE #{name}") end |