diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-17 10:14:22 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-01-17 10:14:22 +0100 |
commit | 641e342d797b0f22bd0496ea460b9ac87f10d24a (patch) | |
tree | b0f53d6acaa4a9ef8fdf506f6e05c0dcaa9d0e41 | |
parent | 65c77e80fc100d16c51a634639032fe43f2f2908 (diff) | |
download | zorglub-641e342d797b0f22bd0496ea460b9ac87f10d24a.zip zorglub-641e342d797b0f22bd0496ea460b9ac87f10d24a.tar.gz |
Node: before_all and after_all hooks are based on inherited_vars
-rw-r--r-- | lib/zorglub/node.rb | 24 |
1 files 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 |