From 641e342d797b0f22bd0496ea460b9ac87f10d24a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 17 Jan 2012 10:14:22 +0100 Subject: Node: before_all and after_all hooks are based on inherited_vars --- lib/zorglub/node.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index 14a6a56..f889259 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -170,32 +170,30 @@ module Zorglub d end # - # TODO use inherited_vars ?? + # before_all and after_all hooks # - @hooks = { - :before_all => [], - :after_all => [], - } + @inherited_vars[:before_all] = [] + @inherited_vars[:after_all] = [] class << self # attr_reader :hooks # def call_before_hooks obj - Node.hooks[:before_all].each do |blk| blk.call obj end + @inherited_vars[:before_all].each do |blk| blk.call obj end end # def before_all &blk - Node.hooks[:before_all]<< blk - Node.hooks[:before_all].uniq! + @inherited_vars[:before_all]<< blk + @inherited_vars[:before_all].uniq! end # def call_after_hooks obj - Node.hooks[:after_all].each do |blk| blk.call obj end + @inherited_vars[:after_all].each do |blk| blk.call obj end end # def after_all &blk - Node.hooks[:after_all]<< blk - Node.hooks[:after_all].uniq! + @inherited_vars[:after_all]<< blk + @inherited_vars[:after_all].uniq! end # end @@ -264,7 +262,7 @@ module Zorglub # def feed! state :pre_cb - Node.call_before_hooks self + self.class.call_before_hooks self state :meth @content = self.send @options[:method], *@options[:args] static_path = static @@ -274,7 +272,7 @@ module Zorglub static_page! static_path end state :post_cb - Node.call_after_hooks self + self.class.call_after_hooks self state :finished return @content, @mime end -- cgit v1.1-2-g2b99