No commit activity in last 3 years
No release in over 3 years
Expand _changed? method. Enable to specify changed attribute value
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

activemodel-attribute_changed_specification

Build Status Coverage Status Code Climate Dependency Status Gem Version

Expand _changed? method defined in ActiveModel::Dirty. You can specify changed attribute value.

Installation

Add this gem to your Gemfile

gem 'activemodel-attribute_changed_specification'

Install via bundle

$ bundle

Usage

Specify value changes.

user = User.new
user.name = 'Bob'
user.name_changed?(from: nil, to: 'Bob') # => true
user.name_changed?(from: 'Paul', to: 'Bob') # => false

using only from or to

user = User.new
user.name = 'Bob'
user.name_changed?(to: 'Bob') # => true
user.name_changed?(from: 'Paul') # => false

You can still use original _changed? method.

user = User.new
user.name = 'Bob'
user.name_changed? # => true

Supports

  • 3.2 <= rails < 4.1 (Rails >= supports this format by itself)