0.0
No commit activity in last 3 years
No release in over 3 years
Observes changes and stores object state before the change
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0
>= 0
>= 3.0.0.beta1

Runtime

~> 1.0
 Project Readme

Undo

Build Status Coverage Status Code Climate Gemnasium Build Status Gem Version

Wrapper for Undo gem. Observe changes and stores object state before the change.

Contents

  1. Installation
  2. Usage
  3. Requirements
  4. Contacts
  5. Compatibility
  6. Contributing
  7. Copyright

Installation

Add this line to your application's Gemfile:

gem 'undo-wrapper'

And then execute:

$ bundle

Or install it yourself as:

$ gem install undo-wrapper

Usage

Undo::wrapper allows to wrap object in decorator:

decorated_object = Undo.wrap object
decorated_object.destroy
Undo.restore decorated_object.uuid

decorated_object is a pure decorator, so it quacks like original object. The Undo will store object state on each hit to mutation methods such as update, delete, destroy. Those methods can be changed either in place or using global configuration.

store_on defines a list of methods which may mutate object state. For each hit to such methods Undo.store will be called.

By default store_on are update, delete, destroy. To append custom store_on use:

Undo::Wrapper.configure do |config|
  config.store_on += [:put, :push, :pop]
end

Undo.wrap object, store_on: [:delete, :destroy]

Or in place:

Undo.wrap object, store_on: :save

Any option, that is not recognized by the Undo as configuration option, will be bypass to the serializer and storage adapter:

Undo.wrap post, include: :comments, expires_in: 1.hour

Requirements

  1. Ruby 1.9 or above
  2. Undo gem

Contacts

Have questions or recommendations? Contact me via alexander.n.paramonov@gmail.com
Found a bug or have enhancement request? You are welcome at Github bugtracker

Compatibility

tested with Ruby

  • 2.1
  • 2.0
  • 1.9.3
  • ruby-head
  • rbx
  • jruby-19mode
  • jruby-head

See build history

Contributing

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

Copyright

Copyright © 2014 Alexander Paramonov. Released under the MIT License. See the LICENSE file for further details.