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
- #default_strategy ⇒ Object
-
#initialize(name, value = 1, &proc) ⇒ Sequence
constructor
:nodoc:.
- #names ⇒ Object
- #next ⇒ Object
Constructor Details
#initialize(name, value = 1, &proc) ⇒ Sequence
:nodoc:
8 9 10 11 12 |
# File 'lib/factory_girl/sequence.rb', line 8 def initialize(name, value = 1, &proc) #:nodoc: @name = name @proc = proc @value = value 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
#default_strategy ⇒ Object
20 21 22 |
# File 'lib/factory_girl/sequence.rb', line 20 def default_strategy :create end |
#names ⇒ Object
24 25 26 |
# File 'lib/factory_girl/sequence.rb', line 24 def names [@name] end |
#next ⇒ Object
14 15 16 17 18 |
# File 'lib/factory_girl/sequence.rb', line 14 def next @proc ? @proc.call(@value) : @value ensure @value = @value.next end |