summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2008-06-10 15:31:00 -0700
committerEric Davis <edavis@littlestreamsoftware.com>2008-07-23 21:04:51 -0700
commit08058e6a027b14c937660f84a557264d892afe28 (patch)
tree7e0cdaadc6830190fa668b59136b97dc575deafe
parent8995245a0c3862b5ed5ce84ea62827a070b77acf (diff)
downloadredmine-08058e6a027b14c937660f84a557264d892afe28.tar.gz
redmine-08058e6a027b14c937660f84a557264d892afe28.zip
Added documentation
-rw-r--r--lib/redmine/plugin.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb
index 72317765b..648203419 100644
--- a/lib/redmine/plugin.rb
+++ b/lib/redmine/plugin.rb
@@ -117,6 +117,14 @@ module Redmine #:nodoc:
@project_module = nil
end
+ # Registers a +method+ to be called when Redmine runs a hook called
+ # +hook_name+
+ #
+ # # Run puts whenever the issue_show hook is called
+ # add_hook :issue_show, Proc.new { puts 'Hello' }
+ #
+ # # Call the class method +my_method+ passing in all the context
+ # add_hook :issue_show, Proc.new {|context| MyPlugin.my_method(context)}
def add_hook(hook_name, method)
Redmine::Plugin::Hook::Manager.add_listener(hook_name, method)
end
@@ -126,7 +134,8 @@ module Redmine #:nodoc:
settings && settings.is_a?(Hash) && !settings[:partial].blank?
end
- # TODO: Doc
+ # Hook is used to allow plugins to hook into Redmine at specific sections
+ # to change it's behavior. See +Redmine::Plugin.add_hook+ for details.
class Hook
class Manager
# Hooks and the procs added
@@ -145,12 +154,11 @@ module Redmine #:nodoc:
class << self
- # TODO: Doc
def valid_hook?(hook_name)
return @@hooks.has_key?(hook_name)
end
- # TODO: Doc
+ # Add +method+ to +hook_name+
def add_listener(hook_name, method)
if valid_hook?(hook_name)
@@hooks[hook_name.to_sym] << method
@@ -158,7 +166,7 @@ module Redmine #:nodoc:
end
end
- # TODO: Doc
+ # Run all the hooks for +hook_name+ passing in +context+
def call_hook(hook_name, context = { })
response = ''
@@hooks[hook_name.to_sym].each do |method|
@@ -167,7 +175,7 @@ module Redmine #:nodoc:
response
end
- # TODO: Doc
+ # Are hooks registered for +hook_name+
def hook_registered?(hook_name)
return @@hooks[hook_name.to_sym].size > 0
end