Class: Spina::Shop::NumberSequence
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Spina::Shop::NumberSequence
- Defined in:
- app/models/spina/shop/number_sequence.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.by_name(name) ⇒ Object
6 7 8 |
# File 'app/models/spina/shop/number_sequence.rb', line 6 def self.by_name(name) NumberSequence.where(name: name).first_or_create! end |
Instance Method Details
#increment! ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/models/spina/shop/number_sequence.rb', line 10 def increment! with_lock do number = next_number self.next_number = number + 1 save! number end end |