Module: Trestle::HookHelper

Defined in:
app/helpers/trestle/hook_helper.rb

Instance Method Summary collapse

Instance Method Details

#hook(name, *args) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'app/helpers/trestle/hook_helper.rb', line 3

def hook(name, *args)
  hooks = hooks(name)

  if hooks.any?
    safe_join(hooks.map { |hook|
      hook.evaluate(self, *args)
    }, "\n")
  elsif block_given?
    capture(*args, &Proc.new)
  end
end

#hook?(name) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'app/helpers/trestle/hook_helper.rb', line 15

def hook?(name)
  hooks(name).any?
end