summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-01-04 02:52:02 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2012-01-04 02:52:02 +0100
commit50b5749972b78a5a4e03e5c2075e884296f0269d (patch)
tree6ed0e56b5614771e78747de286ffea1046fb1430
parentb3e28a42d3982c16f46ea9ec1a02d2f526e1510f (diff)
downloadzorglub-50b5749972b78a5a4e03e5c2075e884296f0269d.zip
zorglub-50b5749972b78a5a4e03e5c2075e884296f0269d.tar.gz
replace helpers with defs
-rw-r--r--lib/zorglub/defs.rb48
-rw-r--r--lib/zorglub/helpers.rb60
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