Sha256: c1c2f593883b20795073b13dbe38a31eb8019226133adca603d421cb4de97f6b

Contents?: true

Size: 435 Bytes

Versions: 3

Compression:

Stored size: 435 Bytes

Contents

module Trestle
  module HookHelper
    def hook(name)
      if hook?(name)
        safe_join(hooks(name).map { |hook|
          hook.evaluate(self)
        }, "\n")
      elsif block_given?
        yield
      end
    end

    def hook?(name)
      Trestle.config.hooks.key?(name.to_s) && hooks(name).any?
    end

  protected
    def hooks(name)
      Trestle.config.hooks[name.to_s].select { |h| h.visible?(self) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trestle-0.8.12 app/helpers/trestle/hook_helper.rb
trestle-0.8.11 app/helpers/trestle/hook_helper.rb
trestle-0.8.10 app/helpers/trestle/hook_helper.rb