Module: Extlib::Hook

Defined in:
lib/extlib/hook.rb

Overview

TODO: Write more documentation!

Overview

The Hook module is a very simple set of AOP helpers. Basically, it allows the developer to specify a method or block that should run before or after another method.

Usage

Halting The Hook Stack

Inheritance

Other Goodies

Please bring up any issues regarding Hooks with carllerche on IRC

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/extlib/hook.rb', line 29

def self.included(base)
  base.extend(ClassMethods)
  base.const_set("CLASS_HOOKS", {}) unless base.const_defined?("CLASS_HOOKS")
  base.const_set("INSTANCE_HOOKS", {}) unless base.const_defined?("INSTANCE_HOOKS")
  base.class_eval do
    class << self
      def method_added(name)
        process_method_added(name, :instance)
        super
      end

      def singleton_method_added(name)
        process_method_added(name, :class)
        super
      end
    end
  end
end