Module: Monad::ClassMethods

Defined in:
lib/do_notation/monad.rb

Instance Method Summary collapse

Instance Method Details

#ruby_for(block) ⇒ Object



7
8
9
10
# File 'lib/do_notation/monad.rb', line 7

def ruby_for block
  @cached_ruby ||= {}
  @cached_ruby[block.to_s] ||= "#{self.name}.instance_eval { #{Ruby2Ruby.new.process(Rewriter.new.process(block.to_method.to_sexp)[2])} }"
end

#run(&block) ⇒ Object



3
4
5
# File 'lib/do_notation/monad.rb', line 3

def run &block
  eval(ruby_for(block), block).call
end