Method: Delorean::Formula#rewrite

Defined in:
lib/delorean/nodes.rb

#rewrite(context) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/delorean/nodes.rb', line 137

def rewrite(context)
  dname = [context.module_name, context.last_node, i.text_value].join('.')
  debug = Debug.debug_set.member?(dname)

  # an attr is defined as a class function on the node class.
  "class #{context.last_node}; " \
    "def self.#{i.text_value}#{POST}(_e); " +
    (debug ? '_debug =' : '') +
    "_e[self.name+'.#{i.text_value}'] ||= #{e.rewrite(context)};" +
    (debug ? 'Delorean::Debug.log(_debug); _debug;' : '') +
    'end; end;'
end