acts_as_removable 1.1.0 → 2.0.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: cca8b02fea9945ffb1dd7187efafbe16fd788dc6
4
- data.tar.gz: b98900fca9e10a29296ca8efd5bf2deb62695797
3
+ metadata.gz: cb77f64473b233261e4953ac268dabcb4f1933fd
4
+ data.tar.gz: c8838df63eb4f7f90d829964dc4dfa449cf0b888
5
5
  SHA512:
6
- metadata.gz: c1669f514ae58f35ee1bb4d1a1e9f3329381c4ef1a24efe6eef1b5ed8ce7bb97c99bec40a4eba31b362ed13459718a7482b97f099933bf64acdd00d83fe64ed4
7
- data.tar.gz: 3a1704d88c080ecc6420f9e754ae66489c4c0a8374662ff6e3e61f65fd773b879197ea78a101fe1aee9898d7fcf8fda1a6f674abc68cacc07d878108c7aef098
6
+ metadata.gz: 60226685f2229482828597606881ebaa19d5e38e1cc65c86fd4f40581de5483668b66bf235e1cb1eddb44655b166a256b0bf8c922806de012e3b328d8fd671d2
7
+ data.tar.gz: 9e10e4d9efb9c24adfc68ad5240fd9aaec312072c853e429f87fb8ba87c8457472dcf6c243dae92a954576fce8a0f0ac7b224e00d52aa767276d0220ce9b3176
@@ -1 +1 @@
1
- ruby-2.0.0
1
+ ruby-2.3.1
@@ -1,7 +1,18 @@
1
+ sudo: false
2
+
1
3
  language: ruby
4
+
2
5
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
6
- - 2.1.1
7
- - 2.1.2
6
+ - 2.2.5
7
+ - 2.3.1
8
+
9
+ gemfile:
10
+ - gemfiles/rails40
11
+ - gemfiles/rails41
12
+ - gemfiles/rails42
13
+ - gemfiles/rails50
14
+
15
+ script: bundle exec rake spec
16
+
17
+ before_install:
18
+ - gem install bundler -v '~> 1.12'
data/README.md CHANGED
@@ -37,13 +37,6 @@ class MyModel < ActiveRecord::Base
37
37
  end
38
38
  ```
39
39
 
40
- It's possible to add a default scope with the active (not removed) records:
41
- ```ruby
42
- class MyModel < ActiveRecord::Base
43
- acts_as_removable with_default_scope: true
44
- end
45
- ```
46
-
47
40
  And you can use callbacks:
48
41
  ```ruby
49
42
  class MyModel < ActiveRecord::Base
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'activesupport', '> 4.0.0'
22
- spec.add_dependency 'activerecord', '> 4.0.0'
21
+ spec.add_dependency 'activesupport', '>= 4.0', '< 6.0'
22
+ spec.add_dependency 'activerecord', '>= 4.0', '< 6.0'
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.3'
25
25
  spec.add_development_dependency 'rake'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-menu-manager.gemspec
4
+ gemspec path: '..'
5
+
6
+
7
+ gem 'railties', '~> 4.0'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-menu-manager.gemspec
4
+ gemspec path: '..'
5
+
6
+
7
+ gem 'railties', '~> 4.1'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-menu-manager.gemspec
4
+ gemspec path: '..'
5
+
6
+
7
+ gem 'railties', '~> 4.2'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails-menu-manager.gemspec
4
+ gemspec path: '..'
5
+
6
+
7
+ gem 'railties', '~> 5.0'
@@ -10,29 +10,21 @@ module ActsAsRemovable
10
10
  #
11
11
  # acts_as_removable
12
12
  # acts_as_removable column_name: 'other_column_name'
13
- # acts_as_removable with_default_scope: true
14
13
  #
15
14
  # ===== Options
16
15
  #
17
16
  # * <tt>:column_name</tt> - A symbol or string with the column to use for removal timestamp.
18
- # * <tt>:with_default_scope</tt> - A boolean indicating to set a default scope with only active (not removed) records
19
17
  def acts_as_removable(options = {})
20
18
  _acts_as_removable_options.merge!(options)
21
19
 
22
20
  scope :removed, -> {
23
- removed_at_column_name = _acts_as_removable_options[:column_name]
24
- query = where(all.table[removed_at_column_name].not_eq(nil).to_sql)
25
- _removable_where_values(query, removed_at_column_name, all.table[removed_at_column_name].eq(nil).to_sql)
21
+ where(all.table[_acts_as_removable_options[:column_name]].not_eq(nil).to_sql)
26
22
  }
27
23
 
28
24
  scope :actives, -> {
29
- removed_at_column_name = _acts_as_removable_options[:column_name]
30
- query = where(all.table[removed_at_column_name].eq(nil).to_sql)
31
- _removable_where_values(query, removed_at_column_name, all.table[removed_at_column_name].not_eq(nil).to_sql)
25
+ where(all.table[_acts_as_removable_options[:column_name]].eq(nil).to_sql)
32
26
  }
33
27
 
34
- default_scope -> {where(all.table[_acts_as_removable_options[:column_name]].eq(nil).to_sql)} if _acts_as_removable_options[:with_default_scope]
35
-
36
28
  define_model_callbacks :remove, :unremove
37
29
 
38
30
  class_eval do
@@ -88,13 +80,6 @@ module ActsAsRemovable
88
80
  column_name: 'removed_at'
89
81
  }
90
82
  end
91
-
92
- # Delete where statements from query
93
- def _removable_where_values(query, column_name, remove_where)
94
- query = query.with_default_scope if query.respond_to?(:with_default_scope)
95
- query.where_values.delete(remove_where)
96
- query
97
- end
98
83
  end
99
84
  end
100
85
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsRemovable
2
- VERSION = '1.1.0'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe 'acts_as_removable' do
4
4
  class MyModel < ActiveRecord::Base
5
- acts_as_removable with_default_scope: true
5
+ acts_as_removable
6
6
  attr_accessor :callback_before_remove, :callback_after_remove, :callback_before_unremove, :callback_after_unremove
7
7
  before_remove do |r|
8
8
  r.callback_before_remove = true
@@ -62,7 +62,7 @@ describe 'acts_as_removable' do
62
62
  MySecondModel.create!
63
63
  MySecondModel.create!.remove!
64
64
 
65
- expect(MyModel.count).to be(1)
65
+ expect(MyModel.count).to be(2)
66
66
  expect(MyModel.actives.count).to be(1)
67
67
  expect(MyModel.removed.count).to be(1)
68
68
  expect(MyModel.unscoped.count).to be(2)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_removable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Schwab
@@ -9,36 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-20 00:00:00.000000000 Z
12
+ date: 2016-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">"
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '4.0'
21
+ - - "<"
19
22
  - !ruby/object:Gem::Version
20
- version: 4.0.0
23
+ version: '6.0'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - ">"
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: '4.0'
31
+ - - "<"
26
32
  - !ruby/object:Gem::Version
27
- version: 4.0.0
33
+ version: '6.0'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: activerecord
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
- - - ">"
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - - "<"
33
42
  - !ruby/object:Gem::Version
34
- version: 4.0.0
43
+ version: '6.0'
35
44
  type: :runtime
36
45
  prerelease: false
37
46
  version_requirements: !ruby/object:Gem::Requirement
38
47
  requirements:
39
- - - ">"
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '4.0'
51
+ - - "<"
40
52
  - !ruby/object:Gem::Version
41
- version: 4.0.0
53
+ version: '6.0'
42
54
  - !ruby/object:Gem::Dependency
43
55
  name: bundler
44
56
  requirement: !ruby/object:Gem::Requirement
@@ -110,6 +122,10 @@ files:
110
122
  - README.md
111
123
  - Rakefile
112
124
  - acts_as_removable.gemspec
125
+ - gemfiles/rails40
126
+ - gemfiles/rails41
127
+ - gemfiles/rails42
128
+ - gemfiles/rails50
113
129
  - lib/acts_as_removable.rb
114
130
  - lib/acts_as_removable/version.rb
115
131
  - spec/acts_as_removable_spec.rb
@@ -134,11 +150,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
150
  version: '0'
135
151
  requirements: []
136
152
  rubyforge_project:
137
- rubygems_version: 2.4.6
153
+ rubygems_version: 2.5.1
138
154
  signing_key:
139
155
  specification_version: 4
140
156
  summary: Simplifies handling of pseudo removed records
141
157
  test_files:
142
158
  - spec/acts_as_removable_spec.rb
143
159
  - spec/spec_helper.rb
144
- has_rdoc: