Class: Fabricators::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/fabricators/sequence.rb

Instance Method Summary collapse

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