kakurenbo-puti 0.1.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +3 -2
- data/lib/kakurenbo_puti/active_record_base.rb +2 -2
- data/lib/kakurenbo_puti/version.rb +1 -1
- data/spec/kakurenbo_puti/active_record_base_spec.rb +5 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/{supports → spec_helpers}/active_record_model.rb +2 -2
- data/spec/{supports → spec_helpers}/active_record_model_spec.rb +0 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8c59a9207db34edcd4372ab1c694575ec46bfc7
|
4
|
+
data.tar.gz: 1a1598872bdc1ce6d2a605285c8330a2ef44a6f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ae299724f9a93eb3e307b4b3accafd6f71419597c10e1cafa5cea6c1d5dd8dd184c8bab41e8793c5ac84d5a1d29443be1e4a0a085aa2393f746dc2d0db10bc9
|
7
|
+
data.tar.gz: 3e30172187a66d883e8cd05ed8741051e93797da9e4c2cd00204de981cde7199b460d120935cd18e39ed271894afcbf55860cd8e3e16b9466b1d10c191225d35
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -28,7 +28,8 @@ Or install it yourself as:
|
|
28
28
|
At first, add `soft_destroyed_at` column to your model.
|
29
29
|
|
30
30
|
```shell
|
31
|
-
rails g migration
|
31
|
+
$ rails g migration AddSoftDestroyedAtToYourModel soft_destroyed_at:datetime:index
|
32
|
+
$ rake db:migrate
|
32
33
|
```
|
33
34
|
|
34
35
|
Next, call `soft_deletable` in model.
|
@@ -64,7 +65,7 @@ model.soft_destroy!
|
|
64
65
|
model.soft_destroyed? # => true
|
65
66
|
```
|
66
67
|
|
67
|
-
|
68
|
+
### Restore record
|
68
69
|
|
69
70
|
```ruby
|
70
71
|
model.restore
|
@@ -60,7 +60,7 @@ module KakurenboPuti
|
|
60
60
|
|
61
61
|
module InstanceMethods
|
62
62
|
# Restore model.
|
63
|
-
# @return [Boolean] Return true if it is
|
63
|
+
# @return [Boolean] Return true if it is successfully restored.
|
64
64
|
def restore
|
65
65
|
true.tap { restore! }
|
66
66
|
rescue
|
@@ -74,7 +74,7 @@ module KakurenboPuti
|
|
74
74
|
end
|
75
75
|
|
76
76
|
# Soft-Delete model.
|
77
|
-
# @return [Boolean] Return true if it is
|
77
|
+
# @return [Boolean] Return true if it is successfully restored.
|
78
78
|
def soft_destroy
|
79
79
|
true.tap { soft_destroy! }
|
80
80
|
rescue
|
@@ -149,8 +149,12 @@ describe KakurenboPuti::ActiveRecordBase do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
context 'When dependent association use in `has_many`' do
|
152
|
+
subject do
|
153
|
+
model_class.without_soft_destroyed
|
154
|
+
end
|
155
|
+
|
152
156
|
let :model_class_options do
|
153
|
-
{dependent_associations: [:soft_delete_children]}
|
157
|
+
{ dependent_associations: [:soft_delete_children] }
|
154
158
|
end
|
155
159
|
|
156
160
|
it 'raise error' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
-
require '
|
3
|
+
require 'spec_helpers/active_record_model'
|
4
4
|
require 'coveralls'
|
5
5
|
require 'kakurenbo-puti'
|
6
6
|
|
@@ -8,6 +8,7 @@ RSpec.configure do |config|
|
|
8
8
|
config.color = true
|
9
9
|
config.mock_framework = :rspec
|
10
10
|
config.before :all do
|
11
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT).tap { |logger| logger.level = Logger::WARN }
|
11
12
|
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
12
13
|
end
|
13
14
|
end
|
@@ -12,7 +12,7 @@ def define_active_record_model(model_name, &block)
|
|
12
12
|
|
13
13
|
tableize_name = Inflector.tableize(model_name)
|
14
14
|
|
15
|
-
before :
|
15
|
+
before :each do
|
16
16
|
migration = ActiveRecord::Migration.new
|
17
17
|
migration.verbose = false
|
18
18
|
migration.create_table tableize_name, &block
|
@@ -25,7 +25,7 @@ def define_active_record_model(model_name, &block)
|
|
25
25
|
Object.const_set model_name, mock_class
|
26
26
|
end
|
27
27
|
|
28
|
-
after :
|
28
|
+
after :each do
|
29
29
|
migration = ActiveRecord::Migration.new
|
30
30
|
migration.verbose = false
|
31
31
|
migration.drop_table tableize_name
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kakurenbo-puti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alfa-jpn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -134,8 +134,8 @@ files:
|
|
134
134
|
- spec/kakurenbo_puti/active_record_base_spec.rb
|
135
135
|
- spec/kakurenbo_puti/situations/deep_nest_spec.rb
|
136
136
|
- spec/spec_helper.rb
|
137
|
-
- spec/
|
138
|
-
- spec/
|
137
|
+
- spec/spec_helpers/active_record_model.rb
|
138
|
+
- spec/spec_helpers/active_record_model_spec.rb
|
139
139
|
homepage: https://github.com/alfa-jpn/kakurenbo-puti
|
140
140
|
licenses:
|
141
141
|
- MIT
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.5.1
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Lightweight soft-delete gem.
|
@@ -164,6 +164,6 @@ test_files:
|
|
164
164
|
- spec/kakurenbo_puti/active_record_base_spec.rb
|
165
165
|
- spec/kakurenbo_puti/situations/deep_nest_spec.rb
|
166
166
|
- spec/spec_helper.rb
|
167
|
-
- spec/
|
168
|
-
- spec/
|
167
|
+
- spec/spec_helpers/active_record_model.rb
|
168
|
+
- spec/spec_helpers/active_record_model_spec.rb
|
169
169
|
has_rdoc:
|