mongoid-undo 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -10
- data/lib/mongoid/undo.rb +4 -1
- data/lib/mongoid/undo/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed489fc3104be499bffb28a4288760cdb72eb730
|
4
|
+
data.tar.gz: f0e4fe0ce599a464d4323d4dde5b39cfdfa46708
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/mongoid/undo/version.rb
CHANGED
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.
|
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-
|
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:
|