deleted_at 0.5.0.pre.1 → 0.5.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
- SHA256:
3
- metadata.gz: df0de7db0fb5c4de89e941d080ac07fc08265ae29c2ae550e9e11b1057699763
4
- data.tar.gz: e79f565b01952c39277e5c49f100441c3b19cfd6245056192b8261c4bd33541c
2
+ SHA1:
3
+ metadata.gz: 29aee507393739895b695138545e5c6898c21d95
4
+ data.tar.gz: f52a30d0f52ae37e24641f4e5a9c74324bc75186
5
5
  SHA512:
6
- metadata.gz: 0a18356dbbecaa30e77709349b85797ca3a50edadfde5474f62a3db841b52c28a14285ca4498318d17f4a3bf5b5b1e246936d69087b218e68592e6d99a0affe0
7
- data.tar.gz: e16f8f3c9b010aa85a0922fe2673d14866eb0451a14988edc1bd6be3efe6d83e75993562046c1ea93ec2b188923d0b4e5596031fadd4439ac989369440a838d9
6
+ metadata.gz: 0b5c88eb056b584f4aebcbe24ebf28fd4e84d78dea0d23e39a23d107e48f2f28aac213c5880028bf38896bb395b6ba1e42341665846ec75dd25406afbf237883
7
+ data.tar.gz: 128097c8e330be5ca187adb07b9f5ce8ef45a819400f9028b364c53a4af71d53bf34c6b7f128c6b9f804ae84c7e3176d8d9e0380f5a1d8e90f504d57b054e57a
data/README.md CHANGED
@@ -2,16 +2,16 @@
2
2
  [![Build Status ](https://travis-ci.org/TwilightCoders/deleted_at.svg)](https://travis-ci.org/TwilightCoders/deleted_at)
3
3
  [![Code Climate ](https://api.codeclimate.com/v1/badges/762cdcd63990efa768b0/maintainability)](https://codeclimate.com/github/TwilightCoders/deleted_at/maintainability)
4
4
  [![Test Coverage](https://codeclimate.com/github/TwilightCoders/deleted_at/badges/coverage.svg)](https://codeclimate.com/github/TwilightCoders/deleted_at/coverage)
5
- [![Dependencies ](https://gemnasium.com/badges/github.com/TwilightCoders/deleted_at.svg)](https://gemnasium.com/github.com/TwilightCoders/deleted_at)
5
+ [![Dependencies ](https://badges.depfu.com/badges/5a2fe8068c0eaa5ad0e25a96373f1725/overview.svg)](https://depfu.com/github/TwilightCoders/deleted_at)
6
6
 
7
7
  # DeletedAt
8
8
 
9
- Hide your "deleted" data (unless specifically asked for) without resorting to `default_scope` by leveraging in-line sub-selects.
9
+ Hide your "deleted" data (unless specifically asked for) without resorting to `default_scope` by leveraging in-line sub-selects. (See the [Upgrading](#upgrading) section)
10
10
 
11
11
  ## Requirements
12
12
 
13
13
  - Ruby 2.3+
14
- - ActiveRecord 4.2+
14
+ - ActiveRecord 4.1+
15
15
 
16
16
  ## Installation
17
17
 
@@ -77,6 +77,42 @@ class CreatCommentsTable < ActiveRecord::Migration
77
77
  end
78
78
  ```
79
79
 
80
+ ## [Upgrading](#upgrading)
81
+
82
+ If you've used `deleted_at` prior to v0.5.0, you'll need to migrate your schema. The new version of `deleted_at` no longer uses views, instead constructing a subselect on the relations. This significantly reduces code polution and monkey patching, as well as reducing the runtime memory usage for rails. Your Database will look (and be) a lot cleaner with no `deleted_at` views and your ERDs will be much cleaner as well.
83
+
84
+ Here is an example of a migration for upgrading
85
+ ```
86
+ require 'deleted_at/legacy'
87
+
88
+ DeletedAt.disable
89
+
90
+ class UpgradeDeletedAt < ActiveRecord::Migration
91
+ def up
92
+ # hip hip hooray!
93
+ models.each do |model|
94
+ DeletedAt::Legacy.uninstall(model)
95
+ end
96
+ end
97
+
98
+ def down
99
+ # booo hiss
100
+ models.each do |model|
101
+ DeletedAt::Legacy.install(model)
102
+ end
103
+ end
104
+
105
+ private
106
+
107
+ def models
108
+ [
109
+ User,
110
+ Post
111
+ ]
112
+ end
113
+ end
114
+
115
+ ```
80
116
  ## Development
81
117
 
82
118
  After checking out the repo, run `bundle` to install dependencies. Then, run `bundle exec rspec` to run the tests.
@@ -6,9 +6,8 @@ module DeletedAt
6
6
 
7
7
  def self.prepended(subclass)
8
8
  class << subclass
9
- cattr_accessor :deleted_at do
10
- DeletedAt::DEFAULT_OPTIONS
11
- end
9
+ cattr_accessor :deleted_at
10
+ self.deleted_at = {}
12
11
  alias all_without_deleted_at all
13
12
  end
14
13
 
@@ -21,17 +20,17 @@ module DeletedAt
21
20
  end
22
21
 
23
22
  def self.has_deleted_at_column?(klass)
24
- klass.columns.map(&:name).include?(klass.deleted_at[:column].to_s)
23
+ klass.columns.map(&:name).include?(klass.deleted_at.dig(:column).to_s)
25
24
  end
26
25
 
27
26
  module ClassMethods
28
27
 
29
28
  def with_deleted_at(options={}, &block)
30
- return if ::DeletedAt.disabled?
31
-
32
- self.deleted_at.merge(options)
29
+ self.deleted_at = DeletedAt::DEFAULT_OPTIONS.merge(options)
33
30
  self.deleted_at[:proc] = block if block_given?
34
31
 
32
+ return if ::DeletedAt.disabled?
33
+
35
34
  DeletedAt::Core.raise_missing(self) unless Core.has_deleted_at_column?(self)
36
35
 
37
36
  self.prepend(DeletedAt::ActiveRecord)
@@ -1,14 +1,14 @@
1
1
  module DeletedAt
2
2
  module Legacy
3
3
  def self.uninstall(model)
4
- return false unless model.has_deleted_at_column?
4
+ return false unless Core.has_deleted_at_column?(model)
5
5
 
6
6
  uninstall_deleted_view(model)
7
7
  uninstall_present_view(model)
8
8
  end
9
9
 
10
10
  def self.install(model)
11
- return false unless model.has_deleted_at_column?
11
+ return false unless Core.has_deleted_at_column?(model)
12
12
 
13
13
  install_present_view(model)
14
14
  install_deleted_view(model)
@@ -1,3 +1,3 @@
1
1
  module DeletedAt
2
- VERSION = "0.5.0-1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deleted_at
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.pre.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Stevens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-04 00:00:00.000000000 Z
11
+ date: 2018-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '4.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '6'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.2'
29
+ version: '4.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '6'
@@ -100,7 +100,7 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0.7'
103
- description: Default scopes are bad. Don't delete your data. DeletedAt, I choose you!
103
+ description: Default scopes are bad. Don't delete your data.
104
104
  email:
105
105
  - dale@twilightcoders.net
106
106
  executables: []
@@ -123,7 +123,9 @@ licenses:
123
123
  - MIT
124
124
  metadata:
125
125
  allowed_push_host: https://rubygems.org
126
- post_install_message:
126
+ post_install_message: |
127
+ If you're upgrading from < 0.5.0, please follow the upgrade instructions
128
+ on https://github.com/TwilightCoders/deleted_at.
127
129
  rdoc_options: []
128
130
  require_paths:
129
131
  - lib
@@ -134,12 +136,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
136
  version: '2.3'
135
137
  required_rubygems_version: !ruby/object:Gem::Requirement
136
138
  requirements:
137
- - - ">"
139
+ - - ">="
138
140
  - !ruby/object:Gem::Version
139
- version: 1.3.1
141
+ version: '0'
140
142
  requirements: []
141
143
  rubyforge_project:
142
- rubygems_version: 2.7.6
144
+ rubygems_version: 2.5.2.1
143
145
  signing_key:
144
146
  specification_version: 4
145
147
  summary: Soft delete your data, but keep it clean.