Class: ROM::Factory::Attributes::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/factory/attributes/sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Sequence

Returns a new instance of Sequence.


8
9
10
11
12
# File 'lib/rom/factory/attributes/sequence.rb', line 8

def initialize(name, &block)
  @name = name
  @count = 0
  @block = block
end

Instance Attribute Details

#blockObject (readonly)


6
7
8
# File 'lib/rom/factory/attributes/sequence.rb', line 6

def block
  @block
end

#countObject (readonly)


6
7
8
# File 'lib/rom/factory/attributes/sequence.rb', line 6

def count
  @count
end

#nameObject (readonly)


6
7
8
# File 'lib/rom/factory/attributes/sequence.rb', line 6

def name
  @name
end

Instance Method Details

#call(*args) ⇒ Object


14
15
16
# File 'lib/rom/factory/attributes/sequence.rb', line 14

def call(*args)
  block.call(increment, *args)
end

#dependency_namesObject


26
27
28
# File 'lib/rom/factory/attributes/sequence.rb', line 26

def dependency_names
  EMPTY_ARRAY
end

#incrementObject


22
23
24
# File 'lib/rom/factory/attributes/sequence.rb', line 22

def increment
  @count += 1
end

#parametersObject


30
31
32
# File 'lib/rom/factory/attributes/sequence.rb', line 30

def parameters
  block.parameters
end

#to_procObject


18
19
20
# File 'lib/rom/factory/attributes/sequence.rb', line 18

def to_proc
  method(:call).to_proc
end