Class: FactoryGirl::Sequence
- Inherits:
-
Object
- Object
- FactoryGirl::Sequence
- Defined in:
- lib/factory_girl/sequence.rb
Overview
Sequences are defined using sequence within a FactoryGirl.define block. Sequence values are generated using next.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, *args, &proc) ⇒ Sequence
constructor
:nodoc:.
- #names ⇒ Object
- #next ⇒ Object
Constructor Details
#initialize(name, *args, &proc) ⇒ Sequence
:nodoc:
8 9 10 11 12 13 14 15 |
# File 'lib/factory_girl/sequence.rb', line 8 def initialize(name, *args, &proc) #:nodoc: @name = name @proc = proc = args. @value = args.first || 1 @aliases = [:aliases] || [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/factory_girl/sequence.rb', line 6 def name @name end |
Instance Method Details
#names ⇒ Object
23 24 25 |
# File 'lib/factory_girl/sequence.rb', line 23 def names [@name] + @aliases end |
#next ⇒ Object
17 18 19 20 21 |
# File 'lib/factory_girl/sequence.rb', line 17 def next @proc ? @proc.call(@value) : @value ensure @value = @value.next end |