Module: Ghaki::Registry::Plugin

Defined in:
lib/ghaki/registry/plugin.rb

Instance Method Summary collapse

Instance Method Details

#set_plugin_registry(feat_name, opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ghaki/registry/plugin.rb', line 9

def set_plugin_registry feat_name, opts={}
  use_simple = if opts.has_key?(:simple_naming) then opts[:simple_naming] else true end
  feat_nick  = if opts.has_key?(:nick_name)     then opts[:nick_name] else feat_name end
  reg_meth   = if use_simple then :register_plugin else :"register_#{feat_nick}_plugin" end
  Ghaki::Registry::Engine.instance.reserve_feature( feat_name )
  (class << self; self; end).instance_eval do
    define_method reg_meth do |reg_item|
      Ghaki::Registry::Engine.instance.add_plugin( feat_name, reg_item, self )
    end
  end
end