Class: AutoIncrement::Incrementor
- Inherits:
-
Object
- Object
- AutoIncrement::Incrementor
- Defined in:
- lib/auto_increment/incrementor.rb
Overview
AutoIncrement::Incrementor
Instance Method Summary collapse
- #before_create(record) ⇒ Object
-
#initialize(column = nil, options = {}) ⇒ Incrementor
constructor
A new instance of Incrementor.
Constructor Details
#initialize(column = nil, options = {}) ⇒ Incrementor
Returns a new instance of Incrementor.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/auto_increment/incrementor.rb', line 5 def initialize(column = nil, = {}) if column.is_a? Hash = column column = nil end @column = column || [:column] || :code @options = .reverse_merge scope: nil, initial: 1, force: false @options[:scope] = [@options[:scope]] unless @options[:scope].is_a? Array end |
Instance Method Details
#before_create(record) ⇒ Object
16 17 18 19 |
# File 'lib/auto_increment/incrementor.rb', line 16 def before_create(record) @record = record write if can_write? end |