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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd64b9818e00706023f8e7756ceaa5dcdfd6ef01
4
- data.tar.gz: afd0d089858ce9067dfc015e4df141d55f808411
3
+ metadata.gz: c0d2f4720fc5c9eab98d6f37af76dd186969899b
4
+ data.tar.gz: 1c24401c5cb30fbdd9954e48c84b65a74ff61b96
5
5
  SHA512:
6
- metadata.gz: b6c67bc50bda291c33831e20fc0a2680929abe593d2d6515a2311ff9867cb6492901a159467b4e3261bf326488d4432516c3548f92d3a3fd43fba8a85484dc72
7
- data.tar.gz: 9b5d9185ff36a93efacd8eca43777901e89ce07dfad4cbe19f1747edd4fc086b0656ac080f6a049d6dfdb8709d71dd5b923fef20c6252d0a5ab89d0c92da6028
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. Expecting no options.")
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]).map { |attribute| attribute.to_s },
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 },
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 }
@@ -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 = 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
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,
@@ -1,3 +1,3 @@
1
1
  module EffectiveTrash
2
- VERSION = '0.3.2'.freeze
2
+ VERSION = '0.3.3'.freeze
3
3
  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.3.2
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: 2018-09-19 00:00:00.000000000 Z
11
+ date: 2019-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails