Sha256: 288442a5ad73dcbdfe1fcb243815d1807f14199f745e3d1376fb6ffcc93e18b5

Contents?: true

Size: 650 Bytes

Versions: 3

Compression:

Stored size: 650 Bytes

Contents

module MoreViewHooks
  # Manages hooks to be applied into Redmine's templates
  class HookCollection
    def initialize
      @hooks   = {}
      @applied = false
    end

    # Applies all registered view hooks
    def apply!
      @hooks.values.each(&:apply!)
      @applied = true
    end

    # Registers a new view hook
    # @param name [String]
    # @param options [Hash] for Defaced
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redmine-more_view_hooks-0.0.3 lib/more_view_hooks/hook_collection.rb
redmine-more_view_hooks-0.0.2 lib/more_view_hooks/hook_collection.rb
redmine-more_view_hooks-0.0.1 lib/more_view_hooks/hook_collection.rb