class MoreViewHooks::HookCollection

Manages hooks to be applied into Redmine’s templates

Public Class Methods

new() click to toggle source
# File lib/more_view_hooks/hook_collection.rb, line 4
def initialize
  @hooks   = {}
  @applied = false
end

Public Instance Methods

add(name, options) click to toggle source

Registers a new view hook @param name [String] @param options [Hash] for Defaced

# File lib/more_view_hooks/hook_collection.rb, line 18
def add(name, options)
  fail ArgumentError, "A view hook '#{name}' already exists" if @hooks[name]
  context = options.delete(:context)
  hook = @hooks[name] = Hook.new(name, context, options)
  hook.apply! if @applied
end
apply!() click to toggle source

Applies all registered view hooks

# File lib/more_view_hooks/hook_collection.rb, line 10
def apply!
  @hooks.values.each(&:apply!)
  @applied = true
end