Undo

Build Status Gemnasium Build Status Coverage Status Gem Version

ActiveModel serializer for Undo gem.

Contents

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

Installation

Add this line to your application's Gemfile:

gem 'undo-serializer-active_model'

And then execute:

$ bundle

Or install it yourself as:

$ gem install undo-serializer-active_model

Requirements

  1. Ruby >= 1.9
  2. active_model_serializers "~> 0.8"
  3. activesupport (active_model_serializers depends on it too)

Usage

It is required to set somethig___association_class_name as key in active_model_serializer:

class UserSerializer < ActiveModel::Serializer
  attributes *User.attribute_names.map(&:to_sym)
  has_many :roles, key: :has_many___roles
end

Gem is designed to be used with Undo gem.
Add it in global config:

Undo.configure do |config|
  config.serializer = Undo::Serializer::ActiveModel.new
end

or use in place:

Undo.wrap user, serializer: Undo::Serializer::ActiveModel.new
Undo.restore uuid, serializer: Undo::Serializer::ActiveModel.new

In place using the specific serializer from gem active_model_serializers:

Undo.wrap user, serializer: Undo::Serializer::ActiveModel.new(UserSerializer.new(user))

Contacts

Have questions or recommendations? Contact me via [email protected] 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 ( http://github.com/AlexParamonov/undo-serializer-active_model/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

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