purgatory 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.markdown +2 -2
- data/VERSION +1 -1
- data/lib/purgatory/purgatory.rb +7 -3
- data/purgatory.gemspec +4 -4
- data/spec/purgatory_spec.rb +25 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTk3MmQ1NzAxNGRmOThjMWE1NTI4MTFjNjAyMDIyMjlkYWFlMmY0Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDA2Mjc0NzNjYTI5NWEzOWFkY2VjOTQ1YWZhNjZkMzM2MmJhZDdkOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjhjZTRmZGRlMjU5ZDA4OTc4NWU2MzgxMDE4NjcwOWE2ZTcwODM0ZDQ2OTcw
|
10
|
+
NWM1ZWRkZWVjZDc4MGRiODQ3MjE2NmYzNTU1YzhjODhhNTk2MTdhYjdhNmVk
|
11
|
+
MzI2ZDc2ZjMyYjlmYTI3ZWEyYTk1NzBmZTVjNTlkMjg3MzY3YmY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Nzc1MTUzZDRhYjUxMDYwMGQ4MmM2OTE0OTdiMzJhODA4ODkzYzhhNTRjNjI3
|
14
|
+
N2MxNTJkMzllZDRjNzkzNzc5MGM2MzAxMWNjMGZlOTJkOTc1NmY0NDkzMDFm
|
15
|
+
YjAwMjYxZjdiMDIwOTg2ODk1NDMyMjcwZWQ0M2E1MDIyMzUyYTg=
|
data/README.markdown
CHANGED
@@ -41,7 +41,7 @@ You can also put the creation of a new object into Purgatory
|
|
41
41
|
item = Item.new price: 100
|
42
42
|
purgatory = item.purgatory!
|
43
43
|
|
44
|
-
Call .purgatize.method(params) to put a method call into Purgatory. When the purgatory is approved the method will be called on the soul
|
44
|
+
Call .purgatize.method(params) to put a method call into Purgatory. When the purgatory is approved the method will be called on the soul. The purgatory will only be approved if the method returns true to indicate it succeeded.
|
45
45
|
|
46
46
|
#without purgatory:
|
47
47
|
item.increase_price(200)
|
@@ -57,7 +57,7 @@ The following are some attributes of a purgatory:
|
|
57
57
|
purgatory.requested_changes # A hash of the proposed changes. The keys are the attribute names and the values are 2-element arrays where the 1st element is the old value and the 2nd element is the new value
|
58
58
|
purgatory.approver # The user who approved the purgatory
|
59
59
|
purgatory.approved_at # The time when the purgatory was approved
|
60
|
-
purgatory.performable_method # Information about the method to call on the soul when the purgatory is approved
|
60
|
+
purgatory.performable_method # Information about the method to call on the soul when the purgatory is approved. Performable methods should return true if they succeed.
|
61
61
|
|
62
62
|
Here are some handy class and instance methods available to you:
|
63
63
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1.0
|
data/lib/purgatory/purgatory.rb
CHANGED
@@ -44,9 +44,13 @@ class Purgatory < ActiveRecord::Base
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def approve!(approver = nil)
|
47
|
-
return false if approved?
|
48
|
-
if
|
49
|
-
soul.send(performable_method[:method]
|
47
|
+
return false if approved?
|
48
|
+
if performable_method.present?
|
49
|
+
success = soul.send(performable_method[:method], *performable_method[:args])
|
50
|
+
else
|
51
|
+
success = soul_with_changes.save
|
52
|
+
end
|
53
|
+
if success
|
50
54
|
self.approver = approver
|
51
55
|
self.approved_at = Time.now
|
52
56
|
self.soul_id = soul.id
|
data/purgatory.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: purgatory 3.
|
5
|
+
# stub: purgatory 3.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "purgatory"
|
9
|
-
s.version = "3.
|
9
|
+
s.version = "3.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Elan Dubrofsky"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2017-08-17"
|
15
15
|
s.description = "Put your model changes in purgatory and allow them to remain lost souls until they are approved"
|
16
16
|
s.email = "elan.dubrofsky@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -47,7 +47,7 @@ Gem::Specification.new do |s|
|
|
47
47
|
]
|
48
48
|
s.homepage = "http://github.com/financeit/purgatory"
|
49
49
|
s.licenses = ["MIT"]
|
50
|
-
s.rubygems_version = "2.2.
|
50
|
+
s.rubygems_version = "2.2.5"
|
51
51
|
s.summary = "Allow changes to a model to be put in purgatory until they are approved"
|
52
52
|
|
53
53
|
if s.respond_to? :specification_version then
|
data/spec/purgatory_spec.rb
CHANGED
@@ -237,6 +237,30 @@ describe Purgatory do
|
|
237
237
|
end
|
238
238
|
end
|
239
239
|
|
240
|
+
context "approving a performable method that returns false" do
|
241
|
+
before do
|
242
|
+
create_method_call_purgatory
|
243
|
+
@purgatory.soul.stub(:rename).and_return(false)
|
244
|
+
end
|
245
|
+
|
246
|
+
it "should store the soul, requester and performable_method" do
|
247
|
+
@purgatory.soul.should == @widget
|
248
|
+
@purgatory.requester.should == user1
|
249
|
+
@purgatory.performable_method[:method].should == :rename
|
250
|
+
@purgatory.performable_method[:args].should == ['bar']
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should fail when performable method returns false" do
|
254
|
+
@purgatory.approve!(user2).should be_false
|
255
|
+
end
|
256
|
+
|
257
|
+
it "it should not be approved" do
|
258
|
+
@purgatory.should be_present
|
259
|
+
@purgatory.should_not be_approved
|
260
|
+
@purgatory.should be_pending
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
240
264
|
context "approving object change purgatory with attr_accessor" do
|
241
265
|
before do
|
242
266
|
create_object_change_purgatory_with_attr_accessor
|
@@ -673,3 +697,4 @@ describe Purgatory do
|
|
673
697
|
Class.new(klass)
|
674
698
|
end
|
675
699
|
end
|
700
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: purgatory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elan Dubrofsky
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.2.
|
109
|
+
rubygems_version: 2.2.5
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Allow changes to a model to be put in purgatory until they are approved
|