Module: Scripting::Pluggable::ClassMethods

Defined in:
lib/scripting/pluggable.rb

Instance Method Summary collapse

Instance Method Details

#plugin(mod, *args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/scripting/pluggable.rb', line 8

def plugin mod, *args
  current = self.plugins
  unless current.include? mod
    current << mod
    include(mod::InstanceMethods) if mod.const_defined? "InstanceMethods"
    extend(mod::ClassMethods) if mod.const_defined? "ClassMethods"

    if mod.respond_to? :class_init
      mod.class_init(self, *args)
    end
  end
end

#pluginsObject



4
5
6
# File 'lib/scripting/pluggable.rb', line 4

def plugins
  @__plugins__ ||= []
end