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.32 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.31 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.30 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.29 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.28 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.27 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.26 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.25 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.24 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.23 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.22 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.21 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.20 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.18 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.17 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.16 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.15 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.14 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.13 spec/support/cassandra.rb
sessionm-cassandra_object-4.0.12 spec/support/cassandra.rb