Module: Flok::TransitionCompiler

Defined in:
lib/flok/transition_compiler.rb

Class Method Summary collapse

Class Method Details

.compile(rb_src) ⇒ Object

Compile a ruby file containing flok controller definitions (from the transition)



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/flok/transition_compiler.rb', line 7

def self.compile rb_src
  #Execute code in this context, the context will hold all the information
  #that is used to then generate code
  context = TransitionCompilerContext.new
  context.instance_eval(rb_src, __FILE__, __LINE__)

  @src = ""
  ctable_erb = File.read File.join(File.dirname(__FILE__), "./transition_compiler_templates/ttable.js.erb")
  ctable_renderer = ERB.new(ctable_erb)
  @src << ctable_renderer.result(context.get_binding)

  #puts @src

  return @src
end