mongoid-undo 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 733b0d209220876c801f04e9137e83ced99c4fae
4
- data.tar.gz: 19a73d8202018bb7d3e61bc962aee9d700aaa8d9
3
+ metadata.gz: ed489fc3104be499bffb28a4288760cdb72eb730
4
+ data.tar.gz: f0e4fe0ce599a464d4323d4dde5b39cfdfa46708
5
5
  SHA512:
6
- metadata.gz: 8454e97989f4ac081dc30a4f44658e614c217bec5bf5fc2d08a545cfee41ee5f04d8e32f526fd50ad62a8b45383a490dc4d15e413bae2b441d374cb2f56e2931
7
- data.tar.gz: f9ccebd0c19f711097539050c9b57dc89529d32d76cf235c15ac2c12e8e1ac93a7acc6919b2a1cb26c00ce55dcf309deb35df44e8009d67ebbd73b9900259e24
6
+ metadata.gz: c2074f5ef14a2793e1a0a9c4af36fe0c736ac64e0e7761425b0b0cbda44e540db9464a00e76588b4d42d1221af2ea9f79886961afe603b2e3f0747a5cd4453a7
7
+ data.tar.gz: 0575fc9e3b68fc138af9c9036f7887507b9ea663f13ee38d3a8051c8d948120a368fc900d66308fc87e4553a3a33f615484eb548b51dec091931f5b5c3798c9a
data/README.md CHANGED
@@ -10,7 +10,17 @@ Super simple undo for your Mongoid app, based on both great modules
10
10
  * `Mongoid::Versioning` is used to keep the older versions of your document, so we can restore them.
11
11
  * `Mongoid::Undo` adds an `action` field to your documents, so we can easily determine whether it was created, updated, or destroyed.
12
12
 
13
- But instead of explaining all the details, you should get the idea by looking at the Usage section.
13
+ But instead of explaining all the details, you should get the idea by looking at the [Usage](https://github.com/haihappen/mongoid-undo#usage) section.
14
+
15
+
16
+ ## Installation
17
+
18
+ In your Gemfile:
19
+
20
+ ```ruby
21
+ gem 'mongoid-undo'
22
+ ```
23
+
14
24
 
15
25
  ## Usage
16
26
 
@@ -21,6 +31,7 @@ class Document
21
31
  end
22
32
  ```
23
33
 
34
+
24
35
  ### Creating (and undoing)
25
36
 
26
37
  ```ruby
@@ -34,6 +45,7 @@ document.redo # A nice alias for undo ;)
34
45
  document.persisted? #=> true
35
46
  ```
36
47
 
48
+
37
49
  ### Updating (and undoing)
38
50
 
39
51
  ```ruby
@@ -49,6 +61,7 @@ document.redo
49
61
  document.name #=> 'bar'
50
62
  ```
51
63
 
64
+
52
65
  ### Destroying (and undoing)
53
66
 
54
67
  ```ruby
@@ -64,9 +77,10 @@ document.redo
64
77
  document.persisted? #=> false
65
78
  ```
66
79
 
80
+
67
81
  ### Callbacks
68
82
 
69
- Mongoid::Undo defines two callbacks which are called before and after `undo`, respectively `redo`. Both are based on `ActiveModel::Callbacks`which means they behave like the allready known Rails callbacks.
83
+ Mongoid::Undo defines two callbacks which are called before and after `undo`, respectively `redo`. Both are based on `ActiveModel::Callbacks` which means they behave like the allready known Rails callbacks.
70
84
 
71
85
  ```ruby
72
86
  class Document
@@ -78,17 +92,10 @@ class Document
78
92
  end
79
93
 
80
94
  before_redo { false } # Don't allow redoing.
95
+ end
81
96
  ```
82
97
 
83
98
 
84
- ## Installation
85
-
86
- In your Gemfile:
87
-
88
- ```ruby
89
- gem 'mongoid-undo'
90
- ```
91
-
92
99
  ## Contributing
93
100
 
94
101
  1. Fork it
data/lib/mongoid/undo.rb CHANGED
@@ -14,10 +14,13 @@ module Mongoid
14
14
  index deleted_at: 1
15
15
 
16
16
  [:create, :update, :destroy].each do |action|
17
- set_callback action, :after do
17
+ name = :"set_action_after_#{action}"
18
+
19
+ define_method name do
18
20
  collection.find(atomic_selector).update('$set' => { action: action })
19
21
  reload
20
22
  end
23
+ set_callback action, :after, name
21
24
  end
22
25
 
23
26
  define_model_callbacks :undo, :redo
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Undo
3
- VERSION = '0.10.0'
3
+ VERSION = '0.10.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-undo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Uher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-30 00:00:00.000000000 Z
11
+ date: 2014-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -86,3 +86,4 @@ signing_key:
86
86
  specification_version: 4
87
87
  summary: Super simple undo for your Mongoid app.
88
88
  test_files: []
89
+ has_rdoc: