Sha256: e3714d403d42e5f08cfcf9150cd486d1154b5cd621901f385c2dfaceb753ef29

Contents?: true

Size: 453 Bytes

Versions: 7

Compression:

Stored size: 453 Bytes

Contents

class Mysql2QueryFilter::Plugins
  @@plugins = {}

  def self.register(name, klass)
    name = name.to_s

    if @@plugins.has_key?(name)
      raise "Plugin has already been registered: #{name}"
    end

    @@plugins[name] = klass
  end

  def self.[](name)
    name = name.to_s

    require "mysql2_query_filter/plugin/#{name}"

    plugin = @@plugins[name]

    unless plugin
      raise "Plugin is not found: #{name}"
    end

    plugin
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mysql2_query_filter-0.0.7 lib/mysql2_query_filter/plugins.rb
mysql2_query_filter-0.0.6 lib/mysql2_query_filter/plugins.rb
mysql2_query_filter-0.0.5 lib/mysql2_query_filter/plugins.rb
mysql2_query_filter-0.0.4 lib/mysql2_query_filter/plugins.rb
mysql2_query_filter-0.0.3 lib/mysql2_query_filter/plugins.rb
mysql2_query_filter-0.0.2 lib/mysql2_query_filter/plugins.rb
mysql2_query_filter-0.0.1 lib/mysql2_query_filter/plugins.rb