sequel-paranoid 0.4.0 → 0.4.1

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.
Files changed (2) hide show
  1. data/lib/sequel/plugins/paranoid.rb +8 -2
  2. metadata +2 -2
@@ -10,7 +10,7 @@ module Sequel::Plugins
10
10
  :deleted_scope_name => :deleted,
11
11
  :non_deleted_scope_name => :present,
12
12
  :ignore_deletion_scope_name => :with_deleted,
13
- :enable_default_scope => false
13
+ :enable_default_scope => false
14
14
  }.merge(options)
15
15
 
16
16
  model.instance_eval do
@@ -66,7 +66,13 @@ module Sequel::Plugins
66
66
  #
67
67
 
68
68
  define_method("recover") do
69
- self.class.send(options[:ignore_deletion_scope_name]).where(:id => self.id).update(options[:deleted_at_field_name] => nil)
69
+ self.send("#{options[:deleted_at_field_name]}=".to_sym, nil)
70
+
71
+ if options[:enable_deleted_by] && self.respond_to?(options[:deleted_by_field_name].to_sym)
72
+ self.send("#{options[:deleted_by_field_name]}=", nil)
73
+ end
74
+
75
+ self.save
70
76
  end
71
77
 
72
78
  #
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -50,7 +50,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
50
  version: '0'
51
51
  segments:
52
52
  - 0
53
- hash: 1230543720425849314
53
+ hash: -677491977119614233
54
54
  required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements: