class CptHook::DSL::HookDefinition

Attributes

call_chain[R]
hook_type[R]
method[R]

Public Class Methods

new(method_to_hook, type) click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 8
def initialize(method_to_hook, type)
  @method     = method_to_hook
  @hook_type  = type
  @call_chain = []
end

Public Instance Methods

call(method_to_call) click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 14
def call(method_to_call)
  @call_chain << MethodCall.new(method_to_call)
  self
end
clone(other) click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 38
def clone(other)
  @call_chain = other.call_chain.map { |cc| cc.dup }
  @hook_type = other.hook_type
  @method = other.method
  self
end
contexts(*args) click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 29
def contexts(*args)
  @call_chain.last.contexts.concat args
  self
end
dup() click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 34
def dup
  HookDefinition.new(@method, @hook_type).clone(self)
end
merge(other) click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 45
def merge(other)
  dup.merge!(other)
end
merge!(other) click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 49
def merge!(other)
  other.call_chain.each do |cc|
    @call_chain << cc unless @call_chain.any? { |c| c.method == cc.method }
  end
  self
end
using(*args) click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 24
def using(*args)
  @call_chain.last.using(*args)
  self
end
with(*args) click to toggle source
# File lib/cpt_hook/dsl/hook_definition.rb, line 19
def with(*args)
  @call_chain.last.with(*args)
  self
end