3 ms·
The beauty of Ruby is that you only need one metaprogramming call to make a DSL in Ruby. Define all your custom methods in a DSL class, then use instance_exec t
by vinceguidry 8y ago
The beauty of Ruby is that you only need one metaprogramming call to make a DSL in Ruby. Define all your custom methods in a DSL class, then use instance_exec to run the code using the DSL in the context of an instance of that class. The instance can use instance variables to keep track of any state that the DSL requires. Super-elegant.