effective_trash 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/acts_as_trashable.rb +7 -6
- data/lib/effective_trash.rb +1 -5
- 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: c0d2f4720fc5c9eab98d6f37af76dd186969899b
|
4
|
+
data.tar.gz: 1c24401c5cb30fbdd9954e48c84b65a74ff61b96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 322a4d6d987aaa52a181afcc16225b4f01537d430194f8ab81a6b8a22c557fbb8db86213044ea06e3217c153f0e1197926e4926aad228a40975adbf73137ffd9
|
7
|
+
data.tar.gz: 5d03c55908dad4827371a2edb199a2aea6c8724637bcfc86decbc57f3bf0a2adc1553468b1d9e0561365a6460be1108284ae80026b4869917508bea46a47722d
|
@@ -6,7 +6,11 @@ module ActsAsTrashable
|
|
6
6
|
@acts_as_trashable_options = options.try(:first) || {}
|
7
7
|
|
8
8
|
unless @acts_as_trashable_options.kind_of?(Hash)
|
9
|
-
raise ArgumentError.new("invalid arguments passed to (effective_trash) acts_as_trashable.
|
9
|
+
raise ArgumentError.new("invalid arguments passed to (effective_trash) acts_as_trashable.")
|
10
|
+
end
|
11
|
+
|
12
|
+
if (unknown = (@acts_as_trashable_options.keys - [:only, :except])).present?
|
13
|
+
raise ArgumentError.new("unknown keyword: #{unknown.join(', ')}")
|
10
14
|
end
|
11
15
|
|
12
16
|
include ::ActsAsTrashable
|
@@ -22,11 +26,8 @@ module ActsAsTrashable
|
|
22
26
|
|
23
27
|
# Parse Options
|
24
28
|
acts_as_trashable_options = {
|
25
|
-
only: Array(@acts_as_trashable_options[:only])
|
26
|
-
except: Array(@acts_as_trashable_options[:except])
|
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)
|
29
|
+
only: Array(@acts_as_trashable_options[:only]),
|
30
|
+
except: Array(@acts_as_trashable_options[:except]),
|
30
31
|
}
|
31
32
|
|
32
33
|
self.send(:define_method, :acts_as_trashable_options) { acts_as_trashable_options }
|
data/lib/effective_trash.rb
CHANGED
@@ -44,11 +44,7 @@ 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 =
|
48
|
-
obj.acts_as_trashable_options.slice(:include_associated, :include_nested)
|
49
|
-
else
|
50
|
-
{ include_associated: true, include_nested: true }
|
51
|
-
end
|
47
|
+
args = (obj.respond_to?(:acts_as_trashable_options) ? obj.acts_as_trashable_options : {})
|
52
48
|
|
53
49
|
trash = Effective::Trash.new(
|
54
50
|
trashed: obj,
|
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.3
|
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:
|
11
|
+
date: 2019-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|