Module: ArrayCollection::Hooks

Included in:
Collect
Defined in:
lib/array_collection/hooks.rb

Overview

Internal hooks

Instance Method Summary collapse

Instance Method Details

#before(method_to_hook, before_method) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/array_collection/hooks.rb', line 6

def before(method_to_hook, before_method)
  alias_method(:"#{method_to_hook}_original", method_to_hook)
  define_method(method_to_hook) do |*args, &block|
    send(before_method)
    send(:"#{method_to_hook}_original", *args, &block)
  end
end