Class: HookItem

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hook_method, weight) ⇒ HookItem

Returns a new instance of HookItem.



5
6
7
8
9
10
11
12
13
14
# File 'lib/vimamsa/hook.rb', line 5

def initialize(hook_method, weight)
  @method_name = hook_method.to_s

  if hook_method.class == Method
    @call_func = hook_method
  elsif hook_method.class == String
    @call_func = method(hook_method)
  end
  @weight = weight
end

Instance Attribute Details

#method_name=(value) ⇒ Object (writeonly)

Sets the attribute method_name

Parameters:

  • value

    the value to set the attribute method_name to.



3
4
5
# File 'lib/vimamsa/hook.rb', line 3

def method_name=(value)
  @method_name = value
end

#weight=(value) ⇒ Object (writeonly)

Sets the attribute weight

Parameters:

  • value

    the value to set the attribute weight to.



3
4
5
# File 'lib/vimamsa/hook.rb', line 3

def weight=(value)
  @weight = value
end

Instance Method Details

#call(x = nil) ⇒ Object



16
17
18
19
# File 'lib/vimamsa/hook.rb', line 16

def call(x = nil)
  @call_func.call(x) if x != nil
  @call_func.call() if x == nil
end