From 8b5ac512744905424c191ea56124a0e7b9f1f787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 8 Jan 2013 00:39:19 +0100 Subject: inherited_vars can be modified at instance level too, but do not impact class level --- lib/zorglub/node.rb | 9 +++++---- spec/spec_helper.rb | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index 6619010..5421046 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -174,12 +174,13 @@ module Zorglub end # def inherited_var sym, *args - d = self.class.inherited_vars[sym].clone || [] + @instance_inherited_vars ||={} + var= @instance_inherited_vars[sym] ||= self.class.inherited_vars[sym].clone || [] unless args.empty? - d.concat args - d.uniq! + var.concat args + var.uniq! end - d + var end # # before_all and after_all hooks diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ee4596e..e710967 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -122,7 +122,8 @@ end # class Node4 < Zorglub::Node no_layout! - inherited_var :js,'js0','js1' + inherited_var :js,'js0' + inherited_var :js,'js1' def index inherited_var(:js).to_yaml end @@ -137,7 +138,8 @@ class Node5 < Node4 # no_layout! inherited from Node4 def index js = inherited_var(:js,'jsx') - css = inherited_var(:css, 'css0', 'css1','css2') + inherited_var(:css, 'css0', 'css1','css2') + css = inherited_var :css js.concat(css).to_yaml end end -- cgit v1.1-2-g2b99