Sha256: 7bc0ab0546896f3bd5516e97695c50196ccc0de6ef7004e231e2c5eb1828a17f

Contents?: true

Size: 625 Bytes

Versions: 13

Compression:

Stored size: 625 Bytes

Contents

module FactoryGirl

  # Raised when calling Factory.sequence from a dynamic attribute block
  class SequenceAbuseError < StandardError; end

  # Sequences are defined using sequence within a FactoryGirl.define block.
  # Sequence values are generated using next.
  class Sequence
    attr_reader :name

    def initialize(name, value = 1, &proc) #:nodoc:
      @name = name
      @proc  = proc
      @value = value || 1
    end

    def next
      @proc ? @proc.call(@value) : @value
    ensure
      @value = @value.next
    end

    def default_strategy
      :create
    end

    def names
      [@name]
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
factory_girl-2.0.4 lib/factory_girl/sequence.rb
factory_girl-2.0.3 lib/factory_girl/sequence.rb
factory_girl-2.0.2 lib/factory_girl/sequence.rb
factory_girl-2.0.1 lib/factory_girl/sequence.rb
factory_girl-2.0.0.rc4 lib/factory_girl/sequence.rb
factory_girl-2.0.0.rc3 lib/factory_girl/sequence.rb
factory_girl-2.0.0.rc2 lib/factory_girl/sequence.rb
factory_girl-2.0.0.rc1 lib/factory_girl/sequence.rb
factory_girl-2.0.0.beta5 lib/factory_girl/sequence.rb
factory_girl-2.0.0.beta4 lib/factory_girl/sequence.rb
factory_girl-2.0.0.beta3 lib/factory_girl/sequence.rb
factory_girl_kibiz0r-2.0.0.beta3 lib/factory_girl/sequence.rb
factory_girl_kibiz0r-2.0.0.beta2 lib/factory_girl/sequence.rb