module DefinedBy class DSL def initialize(&block) @values = [] instance_eval(&block) if block_given? end def <<(array) @values << array end def each(&block) @values.each do |array| yield(array[0], array[1], array[2]) end end def map(&block) @values.map do |array| yield(array[0], array[1], array[2]) end end def method_missing(method, *args, &block) args = *args self << [method.to_sym, args, block] end end class << self def DSL(&block) DSL.new(&block) end end end