Class: Hook

Inherits:
Hash
  • Object
show all
Defined in:
lib/vimamsa/hook.rb

Overview

$hook.register(:puts,“puts”) $hook.call(:puts,“AAAA”)

Instance Method Summary collapse

Constructor Details

#initializeHook

attr_reader :pos, attr_writer :call_func



30
31
# File 'lib/vimamsa/hook.rb', line 30

def initialize()
end

Instance Method Details

#call(hook_id, x = nil) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/vimamsa/hook.rb', line 38

def call(hook_id, x = nil)
  if self[hook_id]
    self[hook_id].each { |hi|
      hi.call(x) if x != nil
      hi.call() if x == nil
    }
  end
end

#register(hook_id, hook_method, weight = 0) ⇒ Object



33
34
35
36
# File 'lib/vimamsa/hook.rb', line 33

def register(hook_id, hook_method, weight = 0)
  self[hook_id] = [] if self[hook_id] == nil
  self[hook_id] << HookItem.new(hook_method, weight)
end