From 50b5749972b78a5a4e03e5c2075e884296f0269d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 4 Jan 2012 02:52:02 +0100 Subject: replace helpers with defs --- lib/zorglub/defs.rb | 48 ++++++++++++++++++++++++++++++++++++++++ lib/zorglub/helpers.rb | 60 -------------------------------------------------- 2 files changed, 48 insertions(+), 60 deletions(-) create mode 100644 lib/zorglub/defs.rb delete mode 100644 lib/zorglub/helpers.rb diff --git a/lib/zorglub/defs.rb b/lib/zorglub/defs.rb new file mode 100644 index 0000000..accbc4d --- /dev/null +++ b/lib/zorglub/defs.rb @@ -0,0 +1,48 @@ +# -*- coding: UTF-8 -*- +# +module Zorglub + # + class Node + # + @defs_h = { + } + # + class << self + # + attr_reader :defs_h + # + # TODO override is maybe not the better way + def inherited sub + sub.layout layout + sub.engine engine + sub.instance_variable_set :@defs_h, {} + @defs_h.each do |d,v| + sub.defs d, *v + end + end + # + def defs sym, *args + unless args.empty? + @defs_h[sym] ||=[] + @defs_h[sym].concat args + @defs_h[sym].uniq! + end + @defs_h[sym] + end + # + end + # + def defs sym, *args + d = self.class.defs_h[sym].clone + unless args.empty? + d ||=[] + d.concat args + d.uniq! + end + d + end + end + # +end +# +# EOF diff --git a/lib/zorglub/helpers.rb b/lib/zorglub/helpers.rb deleted file mode 100644 index 668404e..0000000 --- a/lib/zorglub/helpers.rb +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: UTF-8 -*- -# -module Zorglub - # - module Helpers - # - module Js - def self.included mod - # class level instance variables - mod.instance_variable_set :@js, [] - # class accessors - def mod.js *args - unless args.empty? - @js.concat args - @js.uniq! - end - @js - end - end - # instance accessor - def js *args - @js ||=self.class.js.clone - unless args.empty? - @js.concat args - @js.uniq! - end - @js - end - # - end - # - module Css - def self.included mod - # class level instance variables - mod.instance_variable_set :@css, [] - # class accessors - def mod.css *args - unless args.empty? - @css.concat args - @css.uniq! - end - @css - end - end - # instance accessor - def css *args - @css ||=self.class.css.clone - unless args.empty? - @css.concat args - @css.uniq! - end - @css - end - # - end - end - # -end -# -# EOF -- cgit v1.1-2-g2b99