4 ms·
Metaprogramming is amazing though and in languages that allow it like Ruby make amazing DSLs.
by nwmcsween 8y ago
Metaprogramming is amazing though and in languages that allow it like Ruby make amazing DSLs.
- vinceguidry 8y agoThe 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.