Sha256: e49d936d3c951df4aa715fa4958e457248de20ef1de4b25c4701553847632eda

Contents?: true

Size: 795 Bytes

Versions: 3

Compression:

Stored size: 795 Bytes

Contents

require 'mysql2'

require 'mysql2_query_filter/version'

require 'mysql2_query_filter/mysql2_client_ext'
require 'mysql2_query_filter/plugin'
require 'mysql2_query_filter/plugin/filter'
require 'mysql2_query_filter/plugins'
require 'mysql2_query_filter/query_filter'

Mysql2::Client.class_eval do
  include Mysql2QueryFilter::Mysql2ClientExt
end

module Mysql2QueryFilter
  @@query_filter = Mysql2QueryFilter::QueryFilter.new
  @@enabled = false

  def self.configure
    yield(@@query_filter)
  end

  def self.filter(sql, query_options)
    @@query_filter.filter(sql, query_options) if @@enabled
  end

  def self.enable
    @@enabled = true
  end

  def self.disable
    @@enabled = false
  end

  def self.register(name, klass)
    Mysql2QueryFilter::Plugins.register(name, klass)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mysql2_query_filter-0.0.5 lib/mysql2_query_filter.rb
mysql2_query_filter-0.0.4 lib/mysql2_query_filter.rb
mysql2_query_filter-0.0.3 lib/mysql2_query_filter.rb