Repository is archived
No release in over a year
Automatically switch to writable role on ActiverRecord writable methods.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ActiveRecord::AutoWritable

test

Automatically switch to writable role on ActiverRecord writable methods.

Installation

Add this line to your application's Gemfile:

gem 'active_record-auto_writable'

And then execute:

bundle install

Or install it yourself as:

gem install active_record-auto_writable

Usage

Just install and it works.

Configuration

By default, it wraps all ActiveRecord write methods by ActiveRecord::Base.conneted_to(role: :writing) { ... }. If you want to modify this behavior, set a custom Proc to ActiveRecord::AutoWritable.configuration.proxy.

ActiveRecord::AutoWritable.configuration.proxy = lambda do |&block|
  AnimalRecord.connected_to(role: :zoo_keeper, &block)
end