module Trestle::Hook::Helpers

Public Instance Methods

hook(name, *args, &block) click to toggle source
# File lib/trestle/hook/helpers.rb, line 4
def hook(name, *args, &block)
  hooks = hooks(name)

  if hooks.any?
    safe_join(hooks.map { |hook|
      hook.evaluate(self, *args)
    }, "\n")
  elsif block_given?
    capture(*args, &block)
  end
end
hook?(name) click to toggle source
# File lib/trestle/hook/helpers.rb, line 16
def hook?(name)
  hooks(name).any?
end

Protected Instance Methods

hook_sets() click to toggle source
# File lib/trestle/hook/helpers.rb, line 25
def hook_sets
  @_hook_sets ||= [
    (admin.hooks if defined?(admin) && admin),
    Trestle.config.hooks
  ].compact
end
hooks(name) click to toggle source
# File lib/trestle/hook/helpers.rb, line 21
def hooks(name)
  hook_sets.map { |set| set.for(name) }.inject(&:+).select { |h| h.visible?(self) }
end