guise 0.4.1 → 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/Appraisals +11 -6
- data/README.md +8 -8
- data/gemfiles/3.1.gemfile +2 -2
- data/gemfiles/3.1.gemfile.lock +40 -36
- data/gemfiles/3.2.gemfile +2 -2
- data/gemfiles/3.2.gemfile.lock +39 -35
- data/gemfiles/4.0.gemfile +2 -2
- data/gemfiles/4.0.gemfile.lock +39 -37
- data/gemfiles/4.1.gemfile +8 -0
- data/gemfiles/4.1.gemfile.lock +85 -0
- data/guise.gemspec +3 -3
- data/lib/guise/callbacks.rb +3 -1
- data/lib/guise/syntax.rb +5 -2
- data/lib/guise/version.rb +1 -1
- data/spec/guise_spec.rb +53 -2
- data/spec/spec_helper.rb +3 -1
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb6a6c0e94a4116b19b9b01a4dbb4f6333aeb327
|
4
|
+
data.tar.gz: e826cc373bc0e80600b0ef95db0e2fcb2b8665a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45b14e2a88e8b0dbcb2c3a8d1f1bc9ea5f2f09839f944e8e4decd663737ec4344afd7f51639d7e795027ed12dc3e5a26acba0371119d36b2ef0814b7368489ef
|
7
|
+
data.tar.gz: abca1bdd5f1c859c40c5f2d4b04af0b6e689be95047dc07b14d8d9caae27f30685c581708372088fd5aedba787928a83a39752d9958eefe9d100c0885c05debf
|
data/Appraisals
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
appraise '3.1' do
|
2
|
-
gem 'activerecord', '~> 3.1'
|
3
|
-
gem 'activesupport', '~> 3.1'
|
2
|
+
gem 'activerecord', '~> 3.1.0'
|
3
|
+
gem 'activesupport', '~> 3.1.0'
|
4
4
|
end
|
5
5
|
|
6
6
|
appraise '3.2' do
|
7
|
-
gem 'activerecord', '~> 3.2'
|
8
|
-
gem 'activesupport', '~> 3.2'
|
7
|
+
gem 'activerecord', '~> 3.2.0'
|
8
|
+
gem 'activesupport', '~> 3.2.0'
|
9
9
|
end
|
10
10
|
|
11
11
|
appraise '4.0' do
|
12
|
-
gem 'activerecord', '~> 4.0'
|
13
|
-
gem 'activesupport', '~> 4.0'
|
12
|
+
gem 'activerecord', '~> 4.0.0'
|
13
|
+
gem 'activesupport', '~> 4.0.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
appraise '4.1' do
|
17
|
+
gem 'activerecord', '~> 4.1.0'
|
18
|
+
gem 'activesupport', '~> 4.1.0'
|
14
19
|
end
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ $ gem install guise
|
|
38
38
|
Create a table to store your type information:
|
39
39
|
|
40
40
|
```
|
41
|
-
rails generate model user_role user:references title:string
|
41
|
+
rails generate model user_role user:references title:string:uniq
|
42
42
|
rake db:migrate
|
43
43
|
```
|
44
44
|
|
@@ -48,7 +48,7 @@ the sublcass name will be stored in.
|
|
48
48
|
|
49
49
|
```ruby
|
50
50
|
class User < ActiveRecord::Base
|
51
|
-
has_guises :DeskWorker, :MailForwarder, :
|
51
|
+
has_guises :DeskWorker, :MailForwarder, association: :user_roles, attribute: :title
|
52
52
|
end
|
53
53
|
```
|
54
54
|
|
@@ -131,15 +131,15 @@ with the addition that you can specify not to validate attributes.
|
|
131
131
|
```ruby
|
132
132
|
class Person < ActiveRecord::Base
|
133
133
|
has_guises :Admin, :Engineer,
|
134
|
-
:
|
135
|
-
:
|
136
|
-
:
|
137
|
-
:
|
134
|
+
association: :positions,
|
135
|
+
attribute: :rank,
|
136
|
+
foreign_key: :employee_id,
|
137
|
+
class_name: :JobTitle
|
138
138
|
end
|
139
139
|
|
140
140
|
class JobTitle < ActiveRecord::Base
|
141
141
|
guise_for :Person,
|
142
|
-
:
|
143
|
-
:
|
142
|
+
foreign_key: :employee_id,
|
143
|
+
validate: false # skip setting up validations
|
144
144
|
end
|
145
145
|
```
|
data/gemfiles/3.1.gemfile
CHANGED
data/gemfiles/3.1.gemfile.lock
CHANGED
@@ -1,75 +1,79 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
guise (0.
|
5
|
-
activerecord (>= 3.1, < 4.
|
6
|
-
activesupport (>= 3.1, < 4.
|
4
|
+
guise (0.5.0)
|
5
|
+
activerecord (>= 3.1, < 4.2)
|
6
|
+
activesupport (>= 3.1, < 4.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (3.
|
12
|
-
activesupport (= 3.
|
11
|
+
activemodel (3.1.12)
|
12
|
+
activesupport (= 3.1.12)
|
13
13
|
builder (~> 3.0.0)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
i18n (~> 0.6)
|
15
|
+
activerecord (3.1.12)
|
16
|
+
activemodel (= 3.1.12)
|
17
|
+
activesupport (= 3.1.12)
|
18
|
+
arel (~> 2.2.3)
|
18
19
|
tzinfo (~> 0.3.29)
|
19
|
-
activesupport (3.
|
20
|
-
i18n (~> 0.6, >= 0.6.4)
|
20
|
+
activesupport (3.1.12)
|
21
21
|
multi_json (~> 1.0)
|
22
22
|
appraisal (0.5.2)
|
23
23
|
bundler
|
24
24
|
rake
|
25
|
-
arel (
|
25
|
+
arel (2.2.3)
|
26
26
|
builder (3.0.4)
|
27
|
-
codeclimate-test-reporter (0.
|
27
|
+
codeclimate-test-reporter (0.4.0)
|
28
28
|
simplecov (>= 0.7.1, < 1.0.0)
|
29
29
|
coderay (1.1.0)
|
30
30
|
diff-lcs (1.2.5)
|
31
|
-
docile (1.1.
|
31
|
+
docile (1.1.5)
|
32
32
|
factory_girl (4.4.0)
|
33
33
|
activesupport (>= 3.0.0)
|
34
|
-
i18n (0.6.
|
34
|
+
i18n (0.6.11)
|
35
35
|
method_source (0.8.2)
|
36
|
-
multi_json (1.
|
37
|
-
pry (0.
|
38
|
-
coderay (~> 1.0)
|
39
|
-
method_source (~> 0.8)
|
36
|
+
multi_json (1.10.1)
|
37
|
+
pry (0.10.1)
|
38
|
+
coderay (~> 1.1.0)
|
39
|
+
method_source (~> 0.8.1)
|
40
40
|
slop (~> 3.4)
|
41
|
-
rake (10.
|
42
|
-
rspec (
|
43
|
-
rspec-core (~>
|
44
|
-
rspec-expectations (~>
|
45
|
-
rspec-mocks (~>
|
46
|
-
rspec-core (
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
rake (10.3.2)
|
42
|
+
rspec (3.0.0)
|
43
|
+
rspec-core (~> 3.0.0)
|
44
|
+
rspec-expectations (~> 3.0.0)
|
45
|
+
rspec-mocks (~> 3.0.0)
|
46
|
+
rspec-core (3.0.4)
|
47
|
+
rspec-support (~> 3.0.0)
|
48
|
+
rspec-expectations (3.0.4)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.0.0)
|
51
|
+
rspec-mocks (3.0.4)
|
52
|
+
rspec-support (~> 3.0.0)
|
53
|
+
rspec-support (3.0.4)
|
54
|
+
shoulda-matchers (2.6.2)
|
51
55
|
activesupport (>= 3.0.0)
|
52
|
-
simplecov (0.
|
56
|
+
simplecov (0.9.0)
|
53
57
|
docile (~> 1.1.0)
|
54
58
|
multi_json
|
55
59
|
simplecov-html (~> 0.8.0)
|
56
60
|
simplecov-html (0.8.0)
|
57
|
-
slop (3.
|
58
|
-
sqlite3 (1.3.
|
59
|
-
tzinfo (0.3.
|
61
|
+
slop (3.6.0)
|
62
|
+
sqlite3 (1.3.9)
|
63
|
+
tzinfo (0.3.41)
|
60
64
|
|
61
65
|
PLATFORMS
|
62
66
|
ruby
|
63
67
|
|
64
68
|
DEPENDENCIES
|
65
|
-
activerecord (~> 3.1)
|
66
|
-
activesupport (~> 3.1)
|
69
|
+
activerecord (~> 3.1.0)
|
70
|
+
activesupport (~> 3.1.0)
|
67
71
|
appraisal (~> 0.5)
|
68
72
|
codeclimate-test-reporter (~> 0.3)
|
69
73
|
factory_girl (~> 4.4)
|
70
74
|
guise!
|
71
75
|
pry (~> 0.9)
|
72
76
|
rake (~> 10.1)
|
73
|
-
rspec (~>
|
77
|
+
rspec (~> 3.0)
|
74
78
|
shoulda-matchers (~> 2.5)
|
75
79
|
sqlite3 (~> 1.3)
|
data/gemfiles/3.2.gemfile
CHANGED
data/gemfiles/3.2.gemfile.lock
CHANGED
@@ -1,75 +1,79 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
guise (0.
|
5
|
-
activerecord (>= 3.1, < 4.
|
6
|
-
activesupport (>= 3.1, < 4.
|
4
|
+
guise (0.5.0)
|
5
|
+
activerecord (>= 3.1, < 4.2)
|
6
|
+
activesupport (>= 3.1, < 4.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (3.2.
|
12
|
-
activesupport (= 3.2.
|
11
|
+
activemodel (3.2.13)
|
12
|
+
activesupport (= 3.2.13)
|
13
13
|
builder (~> 3.0.0)
|
14
|
-
activerecord (3.2.
|
15
|
-
activemodel (= 3.2.
|
16
|
-
activesupport (= 3.2.
|
14
|
+
activerecord (3.2.13)
|
15
|
+
activemodel (= 3.2.13)
|
16
|
+
activesupport (= 3.2.13)
|
17
17
|
arel (~> 3.0.2)
|
18
18
|
tzinfo (~> 0.3.29)
|
19
|
-
activesupport (3.2.
|
20
|
-
i18n (
|
19
|
+
activesupport (3.2.13)
|
20
|
+
i18n (= 0.6.1)
|
21
21
|
multi_json (~> 1.0)
|
22
22
|
appraisal (0.5.2)
|
23
23
|
bundler
|
24
24
|
rake
|
25
|
-
arel (3.0.
|
25
|
+
arel (3.0.2)
|
26
26
|
builder (3.0.4)
|
27
|
-
codeclimate-test-reporter (0.
|
27
|
+
codeclimate-test-reporter (0.4.0)
|
28
28
|
simplecov (>= 0.7.1, < 1.0.0)
|
29
29
|
coderay (1.1.0)
|
30
30
|
diff-lcs (1.2.5)
|
31
|
-
docile (1.1.
|
31
|
+
docile (1.1.5)
|
32
32
|
factory_girl (4.4.0)
|
33
33
|
activesupport (>= 3.0.0)
|
34
|
-
i18n (0.6.
|
34
|
+
i18n (0.6.1)
|
35
35
|
method_source (0.8.2)
|
36
|
-
multi_json (1.
|
37
|
-
pry (0.
|
38
|
-
coderay (~> 1.0)
|
39
|
-
method_source (~> 0.8)
|
36
|
+
multi_json (1.10.1)
|
37
|
+
pry (0.10.1)
|
38
|
+
coderay (~> 1.1.0)
|
39
|
+
method_source (~> 0.8.1)
|
40
40
|
slop (~> 3.4)
|
41
|
-
rake (10.
|
42
|
-
rspec (
|
43
|
-
rspec-core (~>
|
44
|
-
rspec-expectations (~>
|
45
|
-
rspec-mocks (~>
|
46
|
-
rspec-core (
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
41
|
+
rake (10.3.2)
|
42
|
+
rspec (3.0.0)
|
43
|
+
rspec-core (~> 3.0.0)
|
44
|
+
rspec-expectations (~> 3.0.0)
|
45
|
+
rspec-mocks (~> 3.0.0)
|
46
|
+
rspec-core (3.0.4)
|
47
|
+
rspec-support (~> 3.0.0)
|
48
|
+
rspec-expectations (3.0.4)
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
+
rspec-support (~> 3.0.0)
|
51
|
+
rspec-mocks (3.0.4)
|
52
|
+
rspec-support (~> 3.0.0)
|
53
|
+
rspec-support (3.0.4)
|
54
|
+
shoulda-matchers (2.6.2)
|
51
55
|
activesupport (>= 3.0.0)
|
52
|
-
simplecov (0.
|
56
|
+
simplecov (0.9.0)
|
53
57
|
docile (~> 1.1.0)
|
54
58
|
multi_json
|
55
59
|
simplecov-html (~> 0.8.0)
|
56
60
|
simplecov-html (0.8.0)
|
57
|
-
slop (3.
|
58
|
-
sqlite3 (1.3.
|
59
|
-
tzinfo (0.3.
|
61
|
+
slop (3.6.0)
|
62
|
+
sqlite3 (1.3.9)
|
63
|
+
tzinfo (0.3.41)
|
60
64
|
|
61
65
|
PLATFORMS
|
62
66
|
ruby
|
63
67
|
|
64
68
|
DEPENDENCIES
|
65
|
-
activerecord (~> 3.2)
|
66
|
-
activesupport (~> 3.2)
|
69
|
+
activerecord (~> 3.2.0)
|
70
|
+
activesupport (~> 3.2.0)
|
67
71
|
appraisal (~> 0.5)
|
68
72
|
codeclimate-test-reporter (~> 0.3)
|
69
73
|
factory_girl (~> 4.4)
|
70
74
|
guise!
|
71
75
|
pry (~> 0.9)
|
72
76
|
rake (~> 10.1)
|
73
|
-
rspec (~>
|
77
|
+
rspec (~> 3.0)
|
74
78
|
shoulda-matchers (~> 2.5)
|
75
79
|
sqlite3 (~> 1.3)
|
data/gemfiles/4.0.gemfile
CHANGED
data/gemfiles/4.0.gemfile.lock
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
guise (0.
|
5
|
-
activerecord (>= 3.1, < 4.
|
6
|
-
activesupport (>= 3.1, < 4.
|
4
|
+
guise (0.5.0)
|
5
|
+
activerecord (>= 3.1, < 4.2)
|
6
|
+
activesupport (>= 3.1, < 4.2)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (4.0.
|
12
|
-
activesupport (= 4.0.
|
11
|
+
activemodel (4.0.9)
|
12
|
+
activesupport (= 4.0.9)
|
13
13
|
builder (~> 3.1.0)
|
14
|
-
activerecord (4.0.
|
15
|
-
activemodel (= 4.0.
|
14
|
+
activerecord (4.0.9)
|
15
|
+
activemodel (= 4.0.9)
|
16
16
|
activerecord-deprecated_finders (~> 1.0.2)
|
17
|
-
activesupport (= 4.0.
|
17
|
+
activesupport (= 4.0.9)
|
18
18
|
arel (~> 4.0.0)
|
19
19
|
activerecord-deprecated_finders (1.0.3)
|
20
|
-
activesupport (4.0.
|
21
|
-
i18n (~> 0.6, >= 0.6.
|
20
|
+
activesupport (4.0.9)
|
21
|
+
i18n (~> 0.6, >= 0.6.9)
|
22
22
|
minitest (~> 4.2)
|
23
23
|
multi_json (~> 1.3)
|
24
24
|
thread_safe (~> 0.1)
|
@@ -27,57 +27,59 @@ GEM
|
|
27
27
|
bundler
|
28
28
|
rake
|
29
29
|
arel (4.0.2)
|
30
|
-
atomic (1.1.14)
|
31
30
|
builder (3.1.4)
|
32
|
-
codeclimate-test-reporter (0.
|
31
|
+
codeclimate-test-reporter (0.4.0)
|
33
32
|
simplecov (>= 0.7.1, < 1.0.0)
|
34
33
|
coderay (1.1.0)
|
35
34
|
diff-lcs (1.2.5)
|
36
|
-
docile (1.1.
|
35
|
+
docile (1.1.5)
|
37
36
|
factory_girl (4.4.0)
|
38
37
|
activesupport (>= 3.0.0)
|
39
|
-
i18n (0.6.
|
38
|
+
i18n (0.6.11)
|
40
39
|
method_source (0.8.2)
|
41
40
|
minitest (4.7.5)
|
42
|
-
multi_json (1.
|
43
|
-
pry (0.
|
44
|
-
coderay (~> 1.0)
|
45
|
-
method_source (~> 0.8)
|
41
|
+
multi_json (1.10.1)
|
42
|
+
pry (0.10.1)
|
43
|
+
coderay (~> 1.1.0)
|
44
|
+
method_source (~> 0.8.1)
|
46
45
|
slop (~> 3.4)
|
47
|
-
rake (10.
|
48
|
-
rspec (
|
49
|
-
rspec-core (~>
|
50
|
-
rspec-expectations (~>
|
51
|
-
rspec-mocks (~>
|
52
|
-
rspec-core (
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
rake (10.3.2)
|
47
|
+
rspec (3.0.0)
|
48
|
+
rspec-core (~> 3.0.0)
|
49
|
+
rspec-expectations (~> 3.0.0)
|
50
|
+
rspec-mocks (~> 3.0.0)
|
51
|
+
rspec-core (3.0.4)
|
52
|
+
rspec-support (~> 3.0.0)
|
53
|
+
rspec-expectations (3.0.4)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.0.0)
|
56
|
+
rspec-mocks (3.0.4)
|
57
|
+
rspec-support (~> 3.0.0)
|
58
|
+
rspec-support (3.0.4)
|
59
|
+
shoulda-matchers (2.6.2)
|
57
60
|
activesupport (>= 3.0.0)
|
58
|
-
simplecov (0.
|
61
|
+
simplecov (0.9.0)
|
59
62
|
docile (~> 1.1.0)
|
60
63
|
multi_json
|
61
64
|
simplecov-html (~> 0.8.0)
|
62
65
|
simplecov-html (0.8.0)
|
63
|
-
slop (3.
|
64
|
-
sqlite3 (1.3.
|
65
|
-
thread_safe (0.
|
66
|
-
|
67
|
-
tzinfo (0.3.38)
|
66
|
+
slop (3.6.0)
|
67
|
+
sqlite3 (1.3.9)
|
68
|
+
thread_safe (0.3.4)
|
69
|
+
tzinfo (0.3.41)
|
68
70
|
|
69
71
|
PLATFORMS
|
70
72
|
ruby
|
71
73
|
|
72
74
|
DEPENDENCIES
|
73
|
-
activerecord (~> 4.0)
|
74
|
-
activesupport (~> 4.0)
|
75
|
+
activerecord (~> 4.0.0)
|
76
|
+
activesupport (~> 4.0.0)
|
75
77
|
appraisal (~> 0.5)
|
76
78
|
codeclimate-test-reporter (~> 0.3)
|
77
79
|
factory_girl (~> 4.4)
|
78
80
|
guise!
|
79
81
|
pry (~> 0.9)
|
80
82
|
rake (~> 10.1)
|
81
|
-
rspec (~>
|
83
|
+
rspec (~> 3.0)
|
82
84
|
shoulda-matchers (~> 2.5)
|
83
85
|
sqlite3 (~> 1.3)
|
@@ -0,0 +1,85 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
guise (0.5.0)
|
5
|
+
activerecord (>= 3.1, < 4.2)
|
6
|
+
activesupport (>= 3.1, < 4.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (4.1.5)
|
12
|
+
activesupport (= 4.1.5)
|
13
|
+
builder (~> 3.1)
|
14
|
+
activerecord (4.1.5)
|
15
|
+
activemodel (= 4.1.5)
|
16
|
+
activesupport (= 4.1.5)
|
17
|
+
arel (~> 5.0.0)
|
18
|
+
activesupport (4.1.5)
|
19
|
+
i18n (~> 0.6, >= 0.6.9)
|
20
|
+
json (~> 1.7, >= 1.7.7)
|
21
|
+
minitest (~> 5.1)
|
22
|
+
thread_safe (~> 0.1)
|
23
|
+
tzinfo (~> 1.1)
|
24
|
+
appraisal (0.5.2)
|
25
|
+
bundler
|
26
|
+
rake
|
27
|
+
arel (5.0.1.20140414130214)
|
28
|
+
builder (3.2.2)
|
29
|
+
codeclimate-test-reporter (0.4.0)
|
30
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
31
|
+
coderay (1.1.0)
|
32
|
+
diff-lcs (1.2.5)
|
33
|
+
docile (1.1.5)
|
34
|
+
factory_girl (4.4.0)
|
35
|
+
activesupport (>= 3.0.0)
|
36
|
+
i18n (0.6.11)
|
37
|
+
json (1.8.1)
|
38
|
+
method_source (0.8.2)
|
39
|
+
minitest (5.4.0)
|
40
|
+
multi_json (1.10.1)
|
41
|
+
pry (0.10.1)
|
42
|
+
coderay (~> 1.1.0)
|
43
|
+
method_source (~> 0.8.1)
|
44
|
+
slop (~> 3.4)
|
45
|
+
rake (10.3.2)
|
46
|
+
rspec (3.0.0)
|
47
|
+
rspec-core (~> 3.0.0)
|
48
|
+
rspec-expectations (~> 3.0.0)
|
49
|
+
rspec-mocks (~> 3.0.0)
|
50
|
+
rspec-core (3.0.4)
|
51
|
+
rspec-support (~> 3.0.0)
|
52
|
+
rspec-expectations (3.0.4)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.0.0)
|
55
|
+
rspec-mocks (3.0.4)
|
56
|
+
rspec-support (~> 3.0.0)
|
57
|
+
rspec-support (3.0.4)
|
58
|
+
shoulda-matchers (2.6.2)
|
59
|
+
activesupport (>= 3.0.0)
|
60
|
+
simplecov (0.9.0)
|
61
|
+
docile (~> 1.1.0)
|
62
|
+
multi_json
|
63
|
+
simplecov-html (~> 0.8.0)
|
64
|
+
simplecov-html (0.8.0)
|
65
|
+
slop (3.6.0)
|
66
|
+
sqlite3 (1.3.9)
|
67
|
+
thread_safe (0.3.4)
|
68
|
+
tzinfo (1.2.2)
|
69
|
+
thread_safe (~> 0.1)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
activerecord (~> 4.1.0)
|
76
|
+
activesupport (~> 4.1.0)
|
77
|
+
appraisal (~> 0.5)
|
78
|
+
codeclimate-test-reporter (~> 0.3)
|
79
|
+
factory_girl (~> 4.4)
|
80
|
+
guise!
|
81
|
+
pry (~> 0.9)
|
82
|
+
rake (~> 10.1)
|
83
|
+
rspec (~> 3.0)
|
84
|
+
shoulda-matchers (~> 2.5)
|
85
|
+
sqlite3 (~> 1.3)
|
data/guise.gemspec
CHANGED
@@ -21,10 +21,10 @@ Gem::Specification.new do |gem|
|
|
21
21
|
|
22
22
|
gem.required_ruby_version = '>= 1.9.3'
|
23
23
|
|
24
|
-
gem.add_dependency "activerecord", ">= 3.1", "< 4.
|
25
|
-
gem.add_dependency "activesupport", ">= 3.1", "< 4.
|
24
|
+
gem.add_dependency "activerecord", ">= 3.1", "< 4.2"
|
25
|
+
gem.add_dependency "activesupport", ">= 3.1", "< 4.2"
|
26
26
|
gem.add_development_dependency 'rake', '~> 10.1'
|
27
|
-
gem.add_development_dependency "rspec", "~>
|
27
|
+
gem.add_development_dependency "rspec", "~> 3.0"
|
28
28
|
gem.add_development_dependency "factory_girl", "~> 4.4"
|
29
29
|
gem.add_development_dependency "shoulda-matchers", "~> 2.5"
|
30
30
|
gem.add_development_dependency "appraisal", '~> 0.5'
|
data/lib/guise/callbacks.rb
CHANGED
data/lib/guise/syntax.rb
CHANGED
@@ -13,7 +13,7 @@ module Guise
|
|
13
13
|
guises = guises.map(&:to_s)
|
14
14
|
association = options.fetch(:association)
|
15
15
|
attribute = options.fetch(:attribute)
|
16
|
-
|
16
|
+
join_table = options[:table_name] || association
|
17
17
|
|
18
18
|
Guise.registry[self.name] = {
|
19
19
|
names: guises,
|
@@ -23,7 +23,7 @@ module Guise
|
|
23
23
|
|
24
24
|
guises.each do |guise|
|
25
25
|
method_name = guise.underscore
|
26
|
-
scope method_name.pluralize, -> { joins(association).where(
|
26
|
+
scope method_name.pluralize, -> { select("#{self.table_name}.*").joins(association).where(join_table => { attribute => guise }) }
|
27
27
|
|
28
28
|
define_method "#{method_name}?" do
|
29
29
|
has_guise?(guise)
|
@@ -36,6 +36,9 @@ module Guise
|
|
36
36
|
association_singular = association.to_s.singularize
|
37
37
|
|
38
38
|
alias_method :guises, association
|
39
|
+
alias_method :guises=, "#{association}="
|
40
|
+
alias_method :guise_ids, "#{association_singular}_ids"
|
41
|
+
alias_method :guise_ids=, "#{association_singular}_ids="
|
39
42
|
alias_method "has_#{association_singular}?", :has_guise?
|
40
43
|
alias_method "has_#{association}?", :has_guises?
|
41
44
|
alias_method "has_any_#{association}?", :has_any_guises?
|
data/lib/guise/version.rb
CHANGED
data/spec/guise_spec.rb
CHANGED
@@ -23,6 +23,25 @@ describe Guise do
|
|
23
23
|
expect(technicians).not_to include supervisor
|
24
24
|
end
|
25
25
|
|
26
|
+
it 'aliases the association methods to `guise=` and `guises=`' do
|
27
|
+
record = create(:user)
|
28
|
+
|
29
|
+
expect(record.guises).to eq []
|
30
|
+
|
31
|
+
# NOTE: The user is assigned in factory_girl to deal with a Rails 3.1
|
32
|
+
# issue
|
33
|
+
record.guises = [build(:user_role, user: record)]
|
34
|
+
record.guises << build(:user_role, name: 'Supervisor', user: record)
|
35
|
+
|
36
|
+
expect(record.guises(true).length).to eq 2
|
37
|
+
|
38
|
+
expect(record.guise_ids.length).to eq 2
|
39
|
+
|
40
|
+
record.guise_ids = []
|
41
|
+
|
42
|
+
expect(record.guises.length).to eq 0
|
43
|
+
end
|
44
|
+
|
26
45
|
it 'handles non-standard table names and foreign key attributes' do
|
27
46
|
person = create(:person)
|
28
47
|
create(:permission, person: person)
|
@@ -126,7 +145,7 @@ describe Guise do
|
|
126
145
|
|
127
146
|
describe '.guise_of' do
|
128
147
|
it "sets default scope to limit to records of the class's type" do
|
129
|
-
technician_ids =
|
148
|
+
technician_ids = User.technicians.map(&:id)
|
130
149
|
|
131
150
|
expect(technician_ids).to eq [technician.id]
|
132
151
|
end
|
@@ -137,6 +156,22 @@ describe Guise do
|
|
137
156
|
|
138
157
|
created_record = Technician.create!
|
139
158
|
expect(created_record).to have_guise :technician
|
159
|
+
|
160
|
+
# Ensure `after_initialize` only runs when the record hasn't been persisted.
|
161
|
+
existing_record = Technician.find(technician.id)
|
162
|
+
expect(existing_record.guises.length).to eq 1
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'sets default scope to ensure records are not readonly' do
|
166
|
+
expect(Technician.first).not_to be_readonly
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'raises an error if no guises are registered for the class' do
|
170
|
+
expect do
|
171
|
+
Class.new(ActiveRecord::Base) do
|
172
|
+
guise_of :Model
|
173
|
+
end
|
174
|
+
end
|
140
175
|
end
|
141
176
|
end
|
142
177
|
|
@@ -162,6 +197,14 @@ describe Guise do
|
|
162
197
|
expect(supervisor_roles).not_to include technician_role
|
163
198
|
end
|
164
199
|
|
200
|
+
it 'raises an error if no guises are registered for the class' do
|
201
|
+
expect do
|
202
|
+
Class.new(ActiveRecord::Base) do
|
203
|
+
guise_for :Model
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
165
208
|
describe "adds validations to ensure guise attribute is" do
|
166
209
|
it "present" do
|
167
210
|
should validate_presence_of(:name)
|
@@ -179,7 +222,7 @@ describe Guise do
|
|
179
222
|
|
180
223
|
describe '.scoped_guise_of' do
|
181
224
|
it 'sets default scope' do
|
182
|
-
names = TechnicianUserRole.
|
225
|
+
names = TechnicianUserRole.all.map(&:name).uniq
|
183
226
|
|
184
227
|
expect(names).to eq ['Technician']
|
185
228
|
end
|
@@ -191,5 +234,13 @@ describe Guise do
|
|
191
234
|
expect(new_technician_role.name).to eq 'Technician'
|
192
235
|
expect(created_technician_role.name).to eq 'Technician'
|
193
236
|
end
|
237
|
+
|
238
|
+
it 'raises an error if no guises are registered for the class' do
|
239
|
+
expect do
|
240
|
+
Class.new(ActiveRecord::Base) do
|
241
|
+
scoped_guise_for :Model
|
242
|
+
end
|
243
|
+
end.to raise_error
|
244
|
+
end
|
194
245
|
end
|
195
246
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,7 +7,9 @@ require 'factory_girl'
|
|
7
7
|
require 'shoulda-matchers'
|
8
8
|
require 'guise'
|
9
9
|
|
10
|
-
I18n.enforce_available_locales
|
10
|
+
if I18n.respond_to?(:enforce_available_locales)
|
11
|
+
I18n.enforce_available_locales = false
|
12
|
+
end
|
11
13
|
|
12
14
|
ActiveRecord::Base.establish_connection(
|
13
15
|
adapter: 'sqlite3',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Gutierrez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '3.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '4.
|
22
|
+
version: '4.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '3.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '4.
|
32
|
+
version: '4.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '3.1'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '4.
|
42
|
+
version: '4.2'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '3.1'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '4.
|
52
|
+
version: '4.2'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: rake
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,14 +70,14 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
73
|
+
version: '3.0'
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
80
|
+
version: '3.0'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: factory_girl
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -183,6 +183,8 @@ files:
|
|
183
183
|
- gemfiles/3.2.gemfile.lock
|
184
184
|
- gemfiles/4.0.gemfile
|
185
185
|
- gemfiles/4.0.gemfile.lock
|
186
|
+
- gemfiles/4.1.gemfile
|
187
|
+
- gemfiles/4.1.gemfile.lock
|
186
188
|
- guise.gemspec
|
187
189
|
- lib/guise.rb
|
188
190
|
- lib/guise/callbacks.rb
|
@@ -213,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
215
|
version: '0'
|
214
216
|
requirements: []
|
215
217
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.2.
|
218
|
+
rubygems_version: 2.2.2
|
217
219
|
signing_key:
|
218
220
|
specification_version: 4
|
219
221
|
summary: Guise provides methods to setup single table inheritance with multiple inheritances
|