Module: Harbor::Hooks

Included in:
Plugin
Defined in:
lib/harbor/hooks.rb

Defined Under Namespace

Modules: ClassMethods Classes: Chain, Map

Class Method Summary collapse

Class Method Details

.included(target) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/harbor/hooks.rb', line 4

def self.included(target)
  target.extend(ClassMethods)

  target.class_eval do
    @__harbor_hooked_method_added = method(:method_added) if respond_to?(:method_added)
    def self.method_added(method)
      if !@__harbor_binding_method && hooks.has_key?(method)
        chain = hooks[method]
        chain.bind!
      end

      @__harbor_hooked_method_added.call(method) if @__harbor_hooked_method_added
    end
  end

end