sequel-paranoid 0.4.3 → 0.6.0

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: f2810c6812fe6196b410c3725df9c1b435a594f5
4
- data.tar.gz: 0554766ead61ca4e1748fd6ec2cf70e6f2741458
3
+ metadata.gz: 27d2f58658899d2edb9cbab4c72e6b61cc9f34ba
4
+ data.tar.gz: 3f781d1eaaaff4df9e7e3193d13dcdd7ed3e75ff
5
5
  SHA512:
6
- metadata.gz: bead23f72dc6c288958907adc1285066c401bc7f32f01ed52c98419c70914a7cfbc7d2885ac5e62217100b4674d72a3b7467baa56026640bf026fba7e327722f
7
- data.tar.gz: 9ba22cf7d5b725c61d5647b2a313b931c5ae45cb47af76e9e76989cdb2339e194b78868370e78f405157515840e567cad11137854362014aa2e340fb6e7a5f99
6
+ metadata.gz: 43571353fa4af350dff6f94ece791bda1f45e442c3005de50d09391f06e39d25b53b488c1d955a9524ebe68857981d4d6d4cf64ae920b18f2cc513ecbbdd4f5c
7
+ data.tar.gz: 7d3e97fd856380d91938f87d364b7c6170da21e11933b4713094b72ea7f9e3665300b35981ecfdc4a308a43aa1090556621ba7578cb152d8e8b2ad026447e8b2
@@ -10,7 +10,8 @@ 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
+ :deleted_column_default => nil
14
15
  }.merge(options)
15
16
 
16
17
  model.instance_eval do
@@ -21,12 +22,12 @@ module Sequel::Plugins
21
22
  dataset_module do
22
23
  # scope for deleted items
23
24
  define_method(options[:deleted_scope_name]) do
24
- send(options[:ignore_deletion_scope_name]).exclude(Sequel.qualify(model.table_name, options[:deleted_at_field_name]) => nil)
25
+ send(options[:ignore_deletion_scope_name]).exclude(Sequel.qualify(model.table_name, options[:deleted_at_field_name]) => options[:deleted_column_default])
25
26
  end
26
27
 
27
28
  # scope for non-deleted items
28
29
  define_method(options[:non_deleted_scope_name]) do
29
- filter(Sequel.qualify(model.table_name, options[:deleted_at_field_name]) => nil)
30
+ filter(Sequel.qualify(model.table_name, options[:deleted_at_field_name]) => options[:deleted_column_default])
30
31
  end
31
32
 
32
33
  # scope for both
@@ -51,7 +52,7 @@ module Sequel::Plugins
51
52
  define_method("_destroy_delete") do
52
53
  # _destroy_delete does not take arguments.
53
54
  destroy_options = Thread.current[:_paranoid_destroy_args].first
54
- Thread.current[:_paranoid_destory_args] = nil
55
+ Thread.current[:_paranoid_destroy_args] = nil
55
56
 
56
57
  # set the deletion time
57
58
  self.send("#{options[:deleted_at_field_name]}=", Time.now)
@@ -69,7 +70,7 @@ module Sequel::Plugins
69
70
  #
70
71
 
71
72
  define_method("recover") do
72
- self.send("#{options[:deleted_at_field_name]}=".to_sym, nil)
73
+ self.send("#{options[:deleted_at_field_name]}=".to_sym, options[:deleted_column_default])
73
74
 
74
75
  if options[:enable_deleted_by] && self.respond_to?(options[:deleted_by_field_name].to_sym)
75
76
  self.send("#{options[:deleted_by_field_name]}=", nil)
@@ -83,7 +84,7 @@ module Sequel::Plugins
83
84
  #
84
85
 
85
86
  define_method("deleted?") do
86
- !!send(options[:deleted_at_field_name])
87
+ send(options[:deleted_at_field_name]) != options[:deleted_column_default]
87
88
  end
88
89
 
89
90
  #
metadata CHANGED
@@ -1,38 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-paranoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sascha Depold
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: Use this plugin to mark a model instance as deleted without loosing its
28
28
  actual data.
29
- email: sascha.depold@blacklane.com
29
+ email: sascha@depold.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - lib/sequel/plugins/paranoid.rb
35
- homepage: https://github.com/blacklane/sequel-paranoid
35
+ homepage: https://github.com/sdepold/sequel-paranoid
36
36
  licenses:
37
37
  - MIT
38
38
  metadata: {}
@@ -42,17 +42,17 @@ require_paths:
42
42
  - lib
43
43
  required_ruby_version: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - '>='
50
+ - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
54
  rubyforge_project:
55
- rubygems_version: 2.0.3
55
+ rubygems_version: 2.4.5
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: A plugin for the Ruby ORM Sequel, that allows soft deletion of database entries.