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 def initialize(value = 1, &proc) #:nodoc: @proc = proc @value = value || 1 end # Returns the next value for this sequence def next @proc ? @proc.call(@value) : @value ensure @value = @value.next end end class << self attr_accessor :sequences #:nodoc: end self.sequences = {} end