29 Mar '13, 10pm
Ruby: How do I build DSLs with yield and instance_eval?
statement is a very important concept to understand when building a Ruby DSL. The functionality provided by yield allows a developer to pass off control temporarily to allow for configuration or advanced functionality. Yielding is a pattern that completely pervades the Ruby language, including the Ruby standard library (the functionality included with the language itself). If you’ve ever used the Array#map (or Array#collect ) functionality, that’s one example of a yield pattern. An example use to increment all the items in an array would look like this: