title: DSL class initialization having issues with number of arguments using instance_eval or block.call
body: <p>I am writing a DSL based on a <a href="https://ilyabylich.svbtle.com/what-is-ruby-dsl" rel="nofollow noreferrer">pattern</a> I have successfully used in the past.  I thought this would work out of the box but I am getting an error that I just can't figure out, so any help is appreciated.</p>
  
  <p>Here is the method to add a test:</p>
  
  <pre><code>module PPEKit
    module Tests
      def add_test(id, &amp;block)
        @_tests ||= {}
        @_tests[id] = Test.new(id, &amp;block) unless @_tests.include? id
      end
    end
  end
  </code></pre>
  
  <p>Here is the Test class definition:</p>
  
  <pre><code>  module Tests
      class Test
        attr_accessor :id, :description, :conditions, :platforms
  
        def initialize(id, &amp;block)
          @id = id
          (block.arity &lt; 1 ? (instance_eval(&amp;block)) : block.call(self)) if block_given? # ERROR occurs here
        end
      end
    end
  </code></pre>
  
  <p>The Tests module is included in a PPEKit::Product class as so:</p>
  
  <pre><code>module PPEKit
    class Product
      include Tests
  </code></pre>
  
  <p>I am not showing method_missing because the error I am getting happens during the instance_eval call.  I have tried initializing the Test object using both types of block arity with the same result:</p>
  
  <pre><code>    add_test :my_test_id do
        description 'my test description'
        conditions  [:minvdd, :maxvdd, :bin1_1300Mhz, :bin2_1200Mhz]
        platforms   [:v93k, :j750]
        meta1       'dkwew'
        meta2       'jkjejkf'
      end
  
      add_test :my_test_id do |t|
        t.description 'my test description'
        t.conditions  [:minvdd, :maxvdd, :bin1_1300Mhz, :bin2_1200Mhz]
        t.platforms   [:v93k, :j750]
        t.meta1       'dkwew'
        t.meta2       'jkjejkf'
      end
  </code></pre>
  
  <p>Both of the definitions above give the following error:</p>
  
  <pre><code>    COMPLETE CALL STACK
      -------------------
      wrong number of arguments (given 1, expected 0)
      /users/user/origen/ppekit/lib/ppekit/test_list.rb:6:in `block in instantiate_tests'
  </code></pre>
  
  <p>Here is a peek at the Test class in pry right before calling instance_eval:</p>
  
  <pre><code>    [1] pry(#&lt;PPEKit::Tests::Test&gt;)&gt; id
      =&gt; :my_test_id
      [2] pry(#&lt;PPEKit::Tests::Test&gt;)&gt; self
      =&gt; #&lt;PPEKit::Tests::Test:0x002b42673ab158&gt;
      [3] pry(#&lt;PPEKit::Tests::Test&gt;)&gt; cd self
      [4] pry(#&lt;PPEKit::Tests::Test&gt;)&gt; block.arity
      =&gt; 0
      [5] pry(#&lt;PPEKit::Tests::Test&gt;)&gt; block
      =&gt; #       &lt;Proc:0x002ab7aff4cab8@/users/user/origen/ppekit/lib/ppekit/test_list.rb:5&gt;
      [6] pry(#&lt;PPEKit::Tests::Test&gt;):1&gt; ls
      PPEKit::Tests::Test#methods:
        conditions  conditions=  description  description=  id  id=  method_missing  platforms  platforms=
      self.methods: __pry__
      locals: _  __  _dir_  _ex_  _file_  _in_  _out_  _pry_
  </code></pre>
  
  <p>Again, thanks in advance.</p>
  
  <p>regards</p>