Class: AutoIncrement::Incrementor

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_increment/incrementor.rb

Overview

AutoIncrement::Incrementor

Instance Method Summary collapse

Constructor Details

#initialize(record, column = nil, **options) ⇒ Incrementor

Returns a new instance of Incrementor.



7
8
9
10
11
12
13
14
15
# File 'lib/auto_increment/incrementor.rb', line 7

def initialize(record, column = nil, **options)
  @record = record
  @column = column || options.fetch(:column, :code)
  @initial = resolve_initial(options)
  @force = options.fetch(:force, false)
  @scope = Array.wrap(options[:scope]).compact
  @model_scope = Array.wrap(options[:model_scope]).compact
  @lock = options.fetch(:lock, false)
end

Instance Method Details

#runObject



17
18
19
# File 'lib/auto_increment/incrementor.rb', line 17

def run
  write if can_write?
end