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:
11 12 13 14 15 |
# File 'lib/factory_girl/sequence.rb', line 11 def initialize(name, value = 1, &proc) #:nodoc: @name = name @proc = proc @value = value || 1 end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/factory_girl/sequence.rb', line 9 def name @name end |
Instance Method Details
#default_strategy ⇒ Object
23 24 25 |
# File 'lib/factory_girl/sequence.rb', line 23 def default_strategy :create end |
#names ⇒ Object
27 28 29 |
# File 'lib/factory_girl/sequence.rb', line 27 def names [@name] 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 |