Sha256: d0a2e1e4f7e33d6ad1315d62b8209aa22cd2b791a3b2b5d7841d56639eb52029

Contents?: true

Size: 1.77 KB

Versions: 8

Compression:

Stored size: 1.77 KB

Contents

# acts_as_removable

This gem allows you to easily manage ActiveRecord objects that are pseudo destroyed a.k.a. removed.

## Installation

Add this line to your application's Gemfile:

    gem 'acts_as_removable'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install acts_as_removable

## Usage

```ruby
# a column removed_at of type timestamp is required
class MyModel < ActiveRecord::Base
  acts_as_removable
end

record = MyModel.create
record.removed? # => false
record.remove
record.removed? # => true
```

You can also specify the column to use:
```ruby
class MyModel < ActiveRecord::Base
  acts_as_removable column_name: :some_column
end
```

And you can use callbacks:
```ruby
class MyModel < ActiveRecord::Base
  acts_as_removable

  before_remove do |r|
    puts "Before removing record"
  end

  after_remove :after_remove_method
  def after_remove_method
    puts "After removing record"
  end

  before_unremove do |r|
    puts "Before unremoving record"
  end

  after_unremove :after_unremove_method
  def after_unremove_method
    puts "After unremoving record"
  end
end
```

## Code Status

* [![Build Status](https://api.travis-ci.org/SICSoftwareGmbH/acts_as_removable.png)](https://travis-ci.org/SICSoftwareGmbH/acts_as_removable)
* [![Dependencies](https://gemnasium.com/SICSoftwareGmbH/acts_as_removable.png?travis)](https://gemnasium.com/SICSoftwareGmbH/acts_as_removable)
* [![Code Climate](https://codeclimate.com/github/SICSoftwareGmbH/acts_as_removable.png)](https://codeclimate.com/github/SICSoftwareGmbH/acts_as_removable)

## Contributing

1. Fork it
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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
acts_as_removable-3.4.0 README.md
acts_as_removable-3.3.0 README.md
acts_as_removable-3.2.0 README.md
acts_as_removable-3.1.1 README.md
acts_as_removable-3.1.0 README.md
acts_as_removable-3.0.1 README.md
acts_as_removable-3.0.0 README.md
acts_as_removable-2.0.0 README.md