Skip to content

Commit

Permalink
enable each plugins to add multiple hooks refs codefirst#140
Browse files Browse the repository at this point in the history
  • Loading branch information
shimomura1004 committed Sep 28, 2013
1 parent 221f55d commit 0d8fc69
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/asakusa_satellite/hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ def self.inherited(klass)
super
end

@@hooks = {}
def self.render_on(hook, options={})
define_method hook do |context|
context[:controller].send(:render_to_string, {:locals => context}.merge(options))
if @@hooks[hook]
@@hooks[hook].push options
else
@@hooks[hook] = [options]
define_method hook do |context|
@@hooks[hook].map{|options| context[:controller].send(:render_to_string, {:locals => context}.merge(options))}.join("\n")
end
end
end

Expand Down

0 comments on commit 0d8fc69

Please sign in to comment.