effective_trash 0.2.5 → 0.2.6
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/app/models/effective/trash.rb +10 -7
- data/app/views/effective/trash/_trash.html.haml +1 -3
- data/lib/effective_trash/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aa7496caf63e3f09ad0778be9ef6c6b4a8667cd
|
4
|
+
data.tar.gz: af51ec535165f1a72c6f1bcf930f4761033bbed3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8cf68d4f4fb439e7b99d6c687d93ac6def8e81707b26903d0de556defa9098c1953ca0ec2ce40c8d2a05f056f51582b179a799c13f4905c34df20e284deb9b6
|
7
|
+
data.tar.gz: 88dede0f9ca2cb31a9b0a75273fecf8d5db4551768718b0e2c22f89bade54748caa5c3857b3804af2b6550ab507672e19292bc1639fe13d3054006d3620f6960
|
@@ -26,10 +26,8 @@ module Effective
|
|
26
26
|
self[:details] || {}
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
def restore!
|
32
|
-
raise 'no attributes to restore from' unless details.kind_of?(Hash) && details[:attributes].present?
|
29
|
+
def to_object
|
30
|
+
raise 'no attributes to consider' unless details.kind_of?(Hash) && details[:attributes].present?
|
33
31
|
|
34
32
|
resource = Effective::Resource.new(trashed_type)
|
35
33
|
object = trashed_type.constantize.new(details[:attributes])
|
@@ -37,15 +35,20 @@ module Effective
|
|
37
35
|
resource.nested_resources.each do |association|
|
38
36
|
if details[association.name].present? && object.respond_to?("#{association.name}_attributes=")
|
39
37
|
nested_attributes = details[association.name].inject({}) do |h, (index, nested)|
|
40
|
-
h[index] = nested[:attributes].except('id', association.inverse_of
|
38
|
+
h[index] = nested[:attributes].except('id', association.inverse_of&.foreign_key); h
|
41
39
|
end
|
42
40
|
|
43
41
|
object.send("#{association.name}_attributes=", nested_attributes)
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
47
|
-
object
|
48
|
-
|
45
|
+
object
|
46
|
+
end
|
47
|
+
|
48
|
+
# So this is a Trash item
|
49
|
+
# When we delete ourselves, we restore this trash item first
|
50
|
+
def restore!
|
51
|
+
to_object.save!(validate: false)
|
49
52
|
end
|
50
53
|
|
51
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_trash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|