secret
Created

using RubyVM::InstructionSequence.disassemble for a DSL

  • Download Gist
yarv_dsl.rb
Ruby
1 2 3 4 5 6 7
def wat &block
method, receiver, *args = RubyVM::InstructionSequence.disassemble(block).scan(/send\s+:(\w+)/).reverse.flatten
{ receiver: receiver, method: method, args: args }
end
 
wat { (puts Kernel test (hello world)) }
#=> {:receiver=>"Kernel", :method=>"puts", :args=>["test", "hello", "world"]}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.