undeletable 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjI3YzE0ZTIyZjIxODVkYTVlOGY2NDlmNTMwMjY5NmE4ZmRhYWE1Yw==
4
+ MDE0YzUzYWUxM2U1ODcwOWQyNWYzYWJmNWJjMDExM2RmNmE2NDc1Ng==
5
5
  data.tar.gz: !binary |-
6
- ZmUxOTc4OTNjZDMzZjRjZDRkNTMxNjAwZDRjMzk1YTY2ODkzNzJhNA==
6
+ Y2YzNTk1ZTFkZDBlYWEwNjc3OTdiNTJjMTA4NjljZDM2MTdkNDIyNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDhjMzQwM2Q4ZDUyYjhiYzllMGU4ZTRiYTc4MWQzZjI5MTk3Nzc5OWNkYjMz
10
- MWE4OGY0ZmZmMGVlMmM2YzdkMmQwYjA0Mjg5MzdhZDVmNjkwM2Y1ZDMxODU1
11
- MDEzODUzM2EzY2U1YjZmZDM0MDg1NzY3ODUzNDk5YzNiZDhlMmY=
9
+ ZjdlMDRlMmFiOGE3OGI4NzgwYzhiYzI1ZDhlZjRkNzU0YWZiMzUyOWY1ODU2
10
+ Y2MzNzZkNjk3ZTRkMmYzZjgwZTljMzI0NmFjYWJmN2U3Y2E3NWFlNGU0YzY3
11
+ ZGFlODFlNWRlZTZjZTZkZWY1YjA0MzhlYTAzZDlmNGQwZmExZTA=
12
12
  data.tar.gz: !binary |-
13
- ODZmYjIxNjA1OGI0M2JlZTI4ZWU3ZDU3NGQzYWE2M2YwMjNkZjkzMjYxMmJi
14
- ZTlhN2UxM2JlNTJhMDdmMzkxZGQ3ODdmZjA3Yzc1NDYyZjYyZGU0MzQ4ZDFk
15
- ZTU5MTdlZjhlM2FhNDY1MzVjNTJjNzBjMDUxMjNjZmRmZjM1NmQ=
13
+ MmQxOTE5MjZiZTM4YzIyY2MzMzliMjYzOWUyN2Q1NjdlMzc2OGY2YTVhYzVi
14
+ ZWJjMTI2YjM1YWI1MjNlNjllOWExYTA0YzU1NzczYzYwMjY2NjYxZWUxMTY5
15
+ OGQzNDAzNDE5NDc3MTU2ZGQ3NzUyOTE5NzIwZGRjYjBlNDMzZmY=
@@ -73,8 +73,12 @@ class ActiveRecord::Relation
73
73
  if klass.respond_to?(:undeletable?) && klass.undeletable?
74
74
  raise ActiveRecord::ReadOnlyRecord.new("#{self} is undeletable") if klass.raise_on_delete?
75
75
  logger.debug("will not #{self}.destroy_all", e) if Undeletable.debug
76
- if conditions
76
+ if args.length > 0 && block_given?
77
77
  where(*args, &block).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset }
78
+ elsif args.length > 0 && !block_given?
79
+ where(*args).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset }
80
+ elsif args.length == 0 && block_given?
81
+ where(&block).to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset }
78
82
  else
79
83
  to_a.each {|object| object.run_callbacks(:destroy) { delete } }.tap { reset }
80
84
  end
@@ -113,8 +117,6 @@ class ActiveRecord::Base
113
117
  private
114
118
 
115
119
  def self.undeletable_init(raise_on_delete_val)
116
- class_attribute :undeletable_enabled, instance_writer: true
117
- self.undeletable_enabled = true
118
120
  class_attribute :raise_on_delete, instance_writer: true
119
121
  self.raise_on_delete = raise_on_delete_val
120
122
  class << self
@@ -1,3 +1,3 @@
1
1
  module Undeletable
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undeletable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary S. Weaver