Class: Ambition::SexpTranslator

Inherits:
Object
  • Object
show all
Defined in:
lib/ambition/sexp_translator.rb

Constant Summary collapse

@@block_cache =
{}

Class Method Summary collapse

Class Method Details

.translate(block) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/ambition/sexp_translator.rb', line 7

def self.translate(block)
  @@block_cache[block.to_s] ||= begin
    klass = Class.new { define_method(:proc_to_method, block) }
    body = ParseTree.translate(klass, :proc_to_method)[2][1..-1]
    [:proc, *body]
  end
end