Low commit activity in last 3 years
No release in over a year
Optimistic lock helper on ActiveRecord.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 12.3.3
~> 3.0
~> 2.2.33

Runtime

>= 0
 Project Readme

WithLockVersion

Build Status

ActiveRecordでlock_versionカラムを使った楽観的ロックをする際に楽になるhelper methodを提供するgemです。

Installation

Add this line to your application's Gemfile:

gem 'with_lock_version'

And then execute:

$ bundle

Or install it yourself as:

$ gem install with_lock_version

Usage

  create_table :orders do |t|
    t.integer :lock_version, default: 1, null: false
    t.timestamps
  end
class Order < ActiveRecord::Base
  with_lock_versionable # required lock_version and timestamp columns 
end
order = Order.find(id)
order.with_lock_version(params[:lock_version]) do
  # something
end

lock_versionが一致しない場合はActiveRecord::StaleObjectErrorをraiseします。

Development

%cp spec/database.yml.sample spec/database.yml
%bundle exec rspec

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bluerabbit/with_lock_version.

License

The gem is available as open source under the terms of the MIT License.