Class: Fabricators::Sequence
- Inherits:
-
Object
- Object
- Fabricators::Sequence
- Defined in:
- lib/fabricators/sequence.rb
Instance Method Summary collapse
- #generate(context) ⇒ Object
-
#initialize(&block) ⇒ Sequence
constructor
A new instance of Sequence.
Constructor Details
#initialize(&block) ⇒ Sequence
Returns a new instance of Sequence.
4 5 6 7 |
# File 'lib/fabricators/sequence.rb', line 4 def initialize(&block) @index = 0 @block = block end |
Instance Method Details
#generate(context) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/fabricators/sequence.rb', line 9 def generate(context) @index += 1 if @block context.instance_exec @index, &@block else @index end end |