Class: FactoryGirl::Sequence Private
- Inherits:
-
Object
- Object
- FactoryGirl::Sequence
- 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)
- - (Object) name readonly private
Instance Method Summary (collapse)
-
- (Sequence) initialize(name, *args, &proc)
constructor
private
A new instance of Sequence.
- - (Object) names private
- - (Object) next private
Constructor Details
- (Sequence) initialize(name, *args, &proc)
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.
A new instance of Sequence
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/factory_girl/sequence.rb', line 9 def initialize(name, *args, &proc) @name = name @proc = proc = args. @value = args.first || 1 @aliases = .fetch(:aliases) { [] } if !@value.respond_to?(:peek) @value = EnumeratorAdapter.new(@value) end end |
Instance Attribute Details
- (Object) name (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
- (Object) names
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.
28 29 30 |
# File 'lib/factory_girl/sequence.rb', line 28 def names [@name] + @aliases end |
- (Object) next
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.
22 23 24 25 26 |
# File 'lib/factory_girl/sequence.rb', line 22 def next @proc ? @proc.call(@value.peek) : @value.peek ensure @value.next end |