module FactoryGirl
  class Attribute #:nodoc:

    class Dynamic < Attribute  #:nodoc:
      def initialize(name, block)
        super(name)
        @block = block
      end

      def add_to(proxy)
        value = @block.arity == 1 ? @block.call(proxy) : proxy.instance_eval(&@block)
        if FactoryGirl::Sequence === value
          raise SequenceAbuseError
        end
        proxy.set(name, value)
      end
    end

  end
end

module FactoryGirl
  class Attribute #:nodoc:

    class Dynamic < Attribute  #:nodoc:
      def initialize(name, block)
        super(name)
        @block = block
      end

      def add_to(proxy)
        value = @block.arity == 1 ? @block.call(proxy) : proxy.instance_exec(&@block)
        if FactoryGirl::Sequence === value
          raise SequenceAbuseError
        end
        proxy.set(name, value)
      end
    end

  end
end

Use instance_exec instead of instance_eval
Use instance_exec instead of instance_eval

In Ruby 1.9.2, instance_eval doesn't yield self anymore, resulting in "wrong number of arguments" error. This should make it compatible with 1.8.7 and 1.9.2

References:
http://www.ruby-forum.com/topic/213313
http://www.ruby-forum.com/topic/189422