Module: VCR::Hooks::ClassMethods

Defined in:
lib/vcr/util/hooks.rb

Instance Method Summary collapse

Instance Method Details

#define_hook(hook_type, prepend = false) ⇒ Object


50
51
52
53
54
55
56
57
58
59
# File 'lib/vcr/util/hooks.rb', line 50

def define_hook(hook_type, prepend = false)
  placement_method = prepend ? :unshift : :<<

  # Put the hook methods in a module so we can override and super to these methods.
  self::DefinedHooks.module_eval do
    define_method hook_type do |*filters, &hook|
      hooks[hook_type].send(placement_method, FilteredHook.new(hook, filters))
    end
  end
end