effective_trash 0.3.1 → 0.3.2
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 +4 -0
- data/app/models/concerns/acts_as_trashable.rb +3 -1
- data/lib/effective_trash.rb +7 -1
- 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: fd64b9818e00706023f8e7756ceaa5dcdfd6ef01
|
4
|
+
data.tar.gz: afd0d089858ce9067dfc015e4df141d55f808411
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6c67bc50bda291c33831e20fc0a2680929abe593d2d6515a2311ff9867cb6492901a159467b4e3261bf326488d4432516c3548f92d3a3fd43fba8a85484dc72
|
7
|
+
data.tar.gz: 9b5d9185ff36a93efacd8eca43777901e89ce07dfad4cbe19f1747edd4fc086b0656ac080f6a049d6dfdb8709d71dd5b923fef20c6252d0a5ab89d0c92da6028
|
data/README.md
CHANGED
@@ -58,6 +58,10 @@ It also serializes the attributes of any `belongs_to`, `has_one`, and `has_many`
|
|
58
58
|
|
59
59
|
Restoring only works with the single base object right now.
|
60
60
|
|
61
|
+
`acts_as_trashable include_associated: false` for cheaper trashes that don't to_s every object.
|
62
|
+
|
63
|
+
`acts_as_trashable include_nested: false` will ignore any nested_attributes, but careful you can lose data when true.
|
64
|
+
|
61
65
|
## Routes
|
62
66
|
|
63
67
|
Visit `/trash`, or `/admin/trash` for an interface to view and restore Trash.
|
@@ -24,7 +24,9 @@ module ActsAsTrashable
|
|
24
24
|
acts_as_trashable_options = {
|
25
25
|
only: Array(@acts_as_trashable_options[:only]).map { |attribute| attribute.to_s },
|
26
26
|
except: Array(@acts_as_trashable_options[:except]).map { |attribute| attribute.to_s },
|
27
|
-
additionally: Array(@acts_as_trashable_options[:additionally]).map { |attribute| attribute.to_s }
|
27
|
+
additionally: Array(@acts_as_trashable_options[:additionally]).map { |attribute| attribute.to_s },
|
28
|
+
include_associated: @acts_as_trashable_options.fetch(:include_associated, true),
|
29
|
+
include_nested: @acts_as_trashable_options.fetch(:include_nested, true)
|
28
30
|
}
|
29
31
|
|
30
32
|
self.send(:define_method, :acts_as_trashable_options) { acts_as_trashable_options }
|
data/lib/effective_trash.rb
CHANGED
@@ -44,12 +44,18 @@ module EffectiveTrash
|
|
44
44
|
# Trash it - Does not delete the original object.
|
45
45
|
# This is run in a before_destroy, or through a script.
|
46
46
|
def self.trash!(obj)
|
47
|
+
args = if obj.respond_to?(:acts_as_trashable_options)
|
48
|
+
obj.acts_as_trashable_options.slice(:include_associated, :include_nested)
|
49
|
+
else
|
50
|
+
{ include_associated: true, include_nested: true }
|
51
|
+
end
|
52
|
+
|
47
53
|
trash = Effective::Trash.new(
|
48
54
|
trashed: obj,
|
49
55
|
user: EffectiveTrash.current_user,
|
50
56
|
trashed_to_s: obj.to_s,
|
51
57
|
trashed_extra: (trashed_extra if obj.respond_to?(:trashed_extra)),
|
52
|
-
details: Effective::Resource.new(obj).instance_attributes
|
58
|
+
details: Effective::Resource.new(obj).instance_attributes(args)
|
53
59
|
).save!
|
54
60
|
end
|
55
61
|
|
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.3.
|
4
|
+
version: 0.3.2
|
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: 2018-
|
11
|
+
date: 2018-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|