Module: Hypertemplate::Builder

Defined in:
lib/hypertemplate/builder.rb,
lib/hypertemplate/builder/xml.rb,
lib/hypertemplate/builder/base.rb,
lib/hypertemplate/builder/json.rb,
lib/hypertemplate/builder/values.rb

Defined Under Namespace

Classes: Base, Json, Values, Xml

Class Method Summary collapse

Class Method Details

.helper_module_for(const) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hypertemplate/builder.rb', line 8

def self.helper_module_for(const)
  mod = Module.new
  mod.module_eval "    def collection(obj, *args, &block)\n      \#{const.name}.build(obj, *args, &block)\n    end\n\n    alias_method :member, :collection\n    \n    def method_missing(sym, *args, &block)\n      \n      # you thought meta-(meta-programming) was nasty?\n      # this is nasty... help me! i am an ActionView\n      # so coupled to the entire Rails stack that I need\n      # this hack.\n      super if @first_invocation\n      @first_invocation = true\n      \n      \#{const.name}.build_dsl(self, :root => sym.to_s, &block)\n    end\n    \n  EOS\n  mod\nend\n"