Module: WithLockVersion::ActiveRecordExt::Core
- Defined in:
- lib/with_lock_version/active_record_ext.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(model) ⇒ Object
14 15 16 |
# File 'lib/with_lock_version/active_record_ext.rb', line 14 def self.included(model) model.extend ClassMethods end |
Instance Method Details
#with_lock_version(target_lock_version) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/with_lock_version/active_record_ext.rb', line 18 def with_lock_version(target_lock_version) unless lock_version.to_i == target_lock_version.to_i raise_error end with_lock do unless lock_version.to_i == target_lock_version.to_i raise_error end touch # Update lock_version + 1 yield end end |