Class: Delorean::Formula

Inherits:
SNode
  • Object
show all
Defined in:
lib/delorean/nodes.rb

Instance Method Summary collapse

Instance Method Details

#check(context) ⇒ Object



125
126
127
# File 'lib/delorean/nodes.rb', line 125

def check(context, *)
  context.parse_define_attr(i.text_value, e.check(context))
end

#rewrite(context) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/delorean/nodes.rb', line 129

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