Module: MuchPlugin

Defined in:
lib/much-plugin.rb,
lib/much-plugin/version.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/much-plugin.rb', line 5

def self.included(receiver)
  receiver.class_eval do
    extend ClassMethods

    # install an included hook that first checks if this plugin has
    # already been installed on the reciever.  If it has not been,
    # class eval each callback on the receiver.

    def self.included(plugin_receiver)
      return if self.much_plugin_receivers.include?(plugin_receiver)

      self.much_plugin_receivers.push(plugin_receiver)
      self.much_plugin_included_hooks.each do |hook|
        plugin_receiver.class_eval(&hook)
      end
    end

  end
end