Module: Falqon::Hooks::ClassMethods

Extended by:
T::Sig
Includes:
Kernel
Defined in:
lib/falqon/concerns/hooks.rb

Instance Method Summary collapse

Instance Method Details

#after(event, method_sym = nil, &block) ⇒ void

This method returns an undefined value.

Add hook to after list (either the given block or a wrapped method call)

Parameters:

  • event (Symbol)

    The event to hook into

  • method_sym (Symbol, nil) (defaults to: nil)

    The method to call

  • block (T.proc.void, nil)

    The block to execute



94
95
96
97
98
# File 'lib/falqon/concerns/hooks.rb', line 94

def after(event, method_sym = nil, &block)
  block ||= proc { send(method_sym) } if method_sym

  T.must(T.must(hooks[event])[:after]) << block if block
end

#before(event, method_sym = nil, &block) ⇒ void

This method returns an undefined value.

Add hook to before list (either the given block or a wrapped method call)

Parameters:

  • event (Symbol)

    The event to hook into

  • method_sym (Symbol, nil) (defaults to: nil)

    The method to call

  • block (T.proc.void, nil)

    The block to execute



80
81
82
83
84
# File 'lib/falqon/concerns/hooks.rb', line 80

def before(event, method_sym = nil, &block)
  block ||= proc { send(method_sym) } if method_sym

  T.must(T.must(hooks[event])[:before]) << block if block
end