Module: Ramaze::Helper::Gestalt
- Defined in:
- lib/ramaze/helper/gestalt.rb
Overview
Gestalt is the custom HTML/XML builder for Ramaze, based on a very simple DSL it will build your markup.
Constant Summary
- CACHE_G =
{}
Instance Method Summary (collapse)
- - (Object) build(&block)
- - (Object) g(meth = nil, view = nil)
- - (Object) g_class
- - (Object) gestalt(&block)
- - (Object) method_missing(sym, *args, &block)
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(sym, *args, &block)
41 42 43 44 |
# File 'lib/ramaze/helper/gestalt.rb', line 41 def method_missing(sym, *args, &block) @gestalt ||= gestalt @gestalt.send(sym, *args, &block) end |
Instance Method Details
- (Object) build(&block)
14 15 16 |
# File 'lib/ramaze/helper/gestalt.rb', line 14 def build(&block) Ramaze::Gestalt.build(&block) end |
- (Object) g(meth = nil, view = nil)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ramaze/helper/gestalt.rb', line 18 def g(meth = nil, view = nil) meth ||= caller[0].slice(/`(.*)'?/).gsub(/[\`\']/, '') view_name = (self.class.to_s.sub('Controller', '') + 'View').split('::') view ||= view_name.inject(Object){ |ns, name| ns.const_get(name) } gestalt_class = CACHE_G[view] ||= g_class gestalt = gestalt_class.new gestalt.extend(view) instance_variables.each do |iv| gestalt.instance_variable_set(iv, instance_variable_get(iv)) end gestalt.__send__(meth) gestalt.to_s end |
- (Object) g_class
33 34 35 36 37 38 39 |
# File 'lib/ramaze/helper/gestalt.rb', line 33 def g_class ancs = self.class.ancestors helpers = Ramaze::Helper.constants.map{ |c| Ramaze::Helper.const_get(c)} our_helpers = ancs & helpers our_helpers.delete(Ramaze::Helper::Gestalt) gestalt_class = Class.new(Ramaze::Gestalt){ include(*our_helpers) } end |
- (Object) gestalt(&block)
10 11 12 |
# File 'lib/ramaze/helper/gestalt.rb', line 10 def gestalt(&block) Ramaze::Gestalt.new(&block) end |