Class: FactoryGirl::Sequence Private

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_girl/sequence.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Sequences are defined using sequence within a FactoryGirl.define block. Sequence values are generated using next.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *args, &proc) ⇒ Sequence

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Sequence.



9
10
11
12
13
14
15
16
# File 'lib/factory_girl/sequence.rb', line 9

def initialize(name, *args, &proc)
  @name    = name
  @proc    = proc

  options  = args.extract_options!
  @value   = args.first || 1
  @aliases = options.fetch(:aliases) { [] }
end

Instance Attribute Details

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



7
8
9
# File 'lib/factory_girl/sequence.rb', line 7

def name
  @name
end

Instance Method Details

#namesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/factory_girl/sequence.rb', line 24

def names
  [@name] + @aliases
end

#nextObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
# File 'lib/factory_girl/sequence.rb', line 18

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