class FactoryBot::Sequence
@api private
Sequence values are generated using next.
Sequences are defined using sequence within a FactoryBot.define block.
def increment_value
def increment_value @value.next end
def initialize(name, *args, &proc)
def initialize(name, *args, &proc) @name = name @proc = proc options = args.extract_options! @value = args.first || 1 @aliases = options.fetch(:aliases) { [] } unless @value.respond_to?(:peek) @value = EnumeratorAdapter.new(@value) end end
def names
def names [@name] + @aliases end
def next(scope = nil)
def next(scope = nil) if @proc && scope scope.instance_exec(value, &@proc) elsif @proc @proc.call(value) else value end ensure increment_value end
def rewind
def rewind @value.rewind end
def value
def value @value.peek end