0.01
No commit activity in last 3 years
No release in over 3 years
A simple and non-intrusive way to mark deprecated columns/attributes in your models. Any usage of these attributes will logged with a warning message and a trace of where the deprecated attribute was called. An exception can be optionally raised as well.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

< 5.0, >= 3.0
~> 1.5
>= 0
= 2.14.1

Runtime

< 5.0, >= 3.0
 Project Readme

attr_deprecated

A simple and non-intrusive way to mark deprecated columns/attributes in your models so they may be more safely removed. Any usage of a deprecated attribute will be logged with a warning message with a trace of where the deprecated attribute was called. Exceptions can be raised as well.

AttrDeprecated is a work in progress

Why?

Because we all have crap we don't want in our schema but are too afraid to remove. Use attr_deprecated to mark specific attributes in a model and will log a deprecation warning if the attribute is called in your code.

attr_deprecated will automatically hook into ActiveModel, however, it can also be used with plain-old Ruby classes.

Installation

gem 'attr_deprecated'

Configuration

AttrDeprecated.configure do |config|
  config.raise = false
  config.notifiers = {
    log: { level: :debug }
  }
end

Usage

In your model:

class User < ActiveRecord::Base
  attr_deprecated :some_deprecated_column, :some_other_deprecated_column

  ...
end

Example:

> User.attr_deprecated
 => <DeprecatedAttributeSet: {"some_deprecated_column", "some_other_deprecated_column"}>
>
> User.attr_deprecated? :some_deprecated_column
 => true
>
> User.new.some_deprecated_column
WARNING: Called deprecated attribute on User: some_deprecated_column
.../.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/irb.rb:396:in `start'
.../.rvm/gems/ruby-2.1.0/gems/railties-3.2.17/lib/rails/commands/console.rb:47:in `start'
.../.rvm/gems/ruby-2.1.0/gems/railties-3.2.17/lib/rails/commands/console.rb:8:in `start'
.../.rvm/gems/ruby-2.1.0/gems/railties-3.2.17/lib/rails/commands.rb:41:in `<top (required)>'
...

Contributing

  1. Fork it ( http://github.com/Aerlinger/attr_deprecated/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request