diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/zorglub/defs.rb | 48 | ||||
-rw-r--r-- | lib/zorglub/helpers.rb | 60 |
2 files changed, 48 insertions, 60 deletions
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 |