Module: Redmine::Hook::Helper

Defined in:
lib/redmine/hook.rb

Overview

Helper module included in ApplicationHelper and ActionControllerso that hooks can be called in views like this:

<%= call_hook(:some_hook) %>
<%= call_hook(:another_hook, :foo => 'bar' %>

Or in controllers like:

call_hook(:some_hook)
call_hook(:another_hook, :foo => 'bar'

Hooks added to views will be concatenated into a string. Hooks added to controllers will return an array of results.

Several objects are automatically added to the call context:

  • project => current project

  • request => Request instance

  • controller => current Controller instance

Instance Method Summary collapse

Instance Method Details

#call_hook(hook, context = {}) ⇒ Object



138
139
140
141
142
143
144
145
146
# File 'lib/redmine/hook.rb', line 138

def call_hook(hook, context={})
  if is_a?(ActionController::Base)
    default_context = {:controller => self, :project => @project, :request => request}
    Redmine::Hook.call_hook(hook, default_context.merge(context))
  else
    default_context = {:controller => controller, :project => @project, :request => request}
    Redmine::Hook.call_hook(hook, default_context.merge(context)).join(' ')
  end        
end