kakurenbo 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/lib/kakurenbo/mixin_ar_base.rb +23 -10
- data/lib/kakurenbo/version.rb +1 -1
- data/spec/kakurenbo/mixin_ar_base_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d17f226c87b76328e3f11a74e9224af2c25ec7d
|
4
|
+
data.tar.gz: 85ecc8c56e701cf1500416a969733c6bb098c1e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28c44c302564b18f8930dac1a90553e83c8bbbf0a3186575eafce1898a75e8902a88c3f0d1a06f02d0064ab3a61e37e1ef6d7bbd1a9ee9bf32a57d3ba7c2f4fa
|
7
|
+
data.tar.gz: 44d3f77630f0872526c21d94761f81e98dbe5e52f43de9e3e7e97fec8ed09f1bc5d8a9b5bfc95096ceebc8b901ef36227316dbfc008d0497db8eb07db48b99f0
|
data/.travis.yml
CHANGED
@@ -8,14 +8,9 @@ module Kakurenbo
|
|
8
8
|
module ClassMethods
|
9
9
|
# Initialize Kakurenbo in child class.
|
10
10
|
def inherited(child_class)
|
11
|
-
child_class.instance_eval
|
12
|
-
|
13
|
-
|
14
|
-
remodel_as_soft_delete
|
15
|
-
rescue
|
16
|
-
# When exec first db:migrate and db:migrate:reset.
|
17
|
-
end
|
18
|
-
}
|
11
|
+
child_class.instance_eval do
|
12
|
+
remodel_as_soft_delete if has_kakurenbo_column?
|
13
|
+
end
|
19
14
|
super
|
20
15
|
end
|
21
16
|
|
@@ -35,10 +30,10 @@ module Kakurenbo
|
|
35
30
|
alias_method :hard_destroy!, :destroy
|
36
31
|
|
37
32
|
class_attribute :kakurenbo_column
|
38
|
-
self.kakurenbo_column = options[:column]
|
39
|
-
|
40
33
|
include Kakurenbo::SoftDeleteCore
|
41
34
|
end
|
35
|
+
|
36
|
+
self.kakurenbo_column = options[:column]
|
42
37
|
end
|
43
38
|
alias_method :acts_as_paranoid, :remodel_as_soft_delete
|
44
39
|
|
@@ -46,6 +41,24 @@ module Kakurenbo
|
|
46
41
|
def paranoid?
|
47
42
|
false
|
48
43
|
end
|
44
|
+
|
45
|
+
# When set table name, remodel.
|
46
|
+
def table_name=(value)
|
47
|
+
super
|
48
|
+
remodel_as_soft_delete if has_kakurenbo_column?
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
# Check if Model has kakurenbo_column.
|
53
|
+
#
|
54
|
+
# @return [Boolean] result.
|
55
|
+
def has_kakurenbo_column?
|
56
|
+
begin
|
57
|
+
column_names.include?('deleted_at')
|
58
|
+
rescue
|
59
|
+
false
|
60
|
+
end
|
61
|
+
end
|
49
62
|
end
|
50
63
|
|
51
64
|
def paranoid?
|
data/lib/kakurenbo/version.rb
CHANGED
@@ -4,6 +4,7 @@ describe Kakurenbo::MixinARBase do
|
|
4
4
|
create_temp_table(:hard_deletes) {}
|
5
5
|
create_temp_table(:soft_deletes) {|t| t.datetime :deleted_at}
|
6
6
|
create_temp_table(:other_columns){|t| t.datetime :destroyed_at}
|
7
|
+
create_temp_table(:other_table_name) {|t| t.datetime :deleted_at}
|
7
8
|
|
8
9
|
context 'when mixin ActiveRecord::Base' do
|
9
10
|
it 'has paranoid? in class methods.'do
|
@@ -54,4 +55,20 @@ describe Kakurenbo::MixinARBase do
|
|
54
55
|
expect(OtherColumn.kakurenbo_column).to eq(:destroyed_at)
|
55
56
|
end
|
56
57
|
end
|
58
|
+
|
59
|
+
context 'when define class of DiffTableName' do
|
60
|
+
before :all do
|
61
|
+
class DiffTableName < ActiveRecord::Base
|
62
|
+
self.table_name='other_table_name'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'table_name is right.' do
|
67
|
+
expect(DiffTableName.table_name).to eq('other_table_name')
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'paranoid? return true.' do
|
71
|
+
expect(DiffTableName.paranoid?).to be_true
|
72
|
+
end
|
73
|
+
end
|
57
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kakurenbo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alfa-jpn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|