Sha256: db710a8e93985a344e611fe5d878a829ebd75892a784e14307071c01085def52

Contents?: true

Size: 999 Bytes

Versions: 30

Compression:

Stored size: 999 Bytes

Contents

require 'cassandra'

module Cassandra
  class Session
    @@populated_column_families = Set.new
    @@test_client = CassandraObject::Adapters::CassandraDriver.new(CassandraObject::Base.connection_spec).client

    def self.truncate_populated_column_family(column_family)
      @@test_client.execute "TRUNCATE \"#{column_family}\""
    end

    def self.delete_all_populated_column_families
      unless @@populated_column_families.empty?
        @@populated_column_families.each { |column_family| self.truncate_populated_column_family(column_family) }
        @@populated_column_families.clear
      end
    end

    [:execute_async].each do |method|
      define_method("#{method}_with_populated_tracking") do |*args|
        send("#{method}_without_populated_tracking", *args).tap do
          if args.first =~ /(insert into|update) "(.+?)"/i
            @@populated_column_families.add $2
          end
        end
      end
      alias_method_chain method, :populated_tracking
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
sessionm-cassandra_object-4.0.11 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.10 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.9 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.8 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.7 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.6 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.5 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.4 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.3 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.2 spec/support/cassandra.rb