Sha256: fd3531504a9dfe7db29c9b681589fb9d3076e7d0a242bedab91c1597653006b7

Contents?: true

Size: 611 Bytes

Versions: 2

Compression:

Stored size: 611 Bytes

Contents

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
defined-by-0.0.6 lib/defined-by/dsl.rb
defined-by-0.0.5 lib/defined-by/dsl.rb