spyke 1.8.6 → 1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spyke/associations/builder.rb +5 -1
- data/lib/spyke/version.rb +1 -1
- data/test/associations_test.rb +5 -0
- data/test/support/fixtures.rb +4 -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: 86fba5601363bb57856a5cd3eb2dce1d37d8514e
|
4
|
+
data.tar.gz: 0fb9a9ae25540cc72fb6aac4513ed3d601e6412e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70ae11278bc7c9e36fdbfc91a0884f3f0a2fbab1a35843df846007c0bb72027af981ab88848716976d528ff38adacee3c392c23c936add6ccabb325613eb5ee8
|
7
|
+
data.tar.gz: 7f6dae12dd72823ef85e26329bd612656b3b2cbcf306a4cef14ce6b6964f5ed27ae60d1623333d4b8fc1d368d95cf67af283a1b362cbe06939bc29ec3a337aab
|
@@ -10,11 +10,15 @@ module Spyke
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def klass
|
13
|
-
@klass ||=
|
13
|
+
@klass ||= custom_class || compute_class(@name)
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
+
def custom_class
|
19
|
+
@options[:class_name].constantize if @options[:class_name]
|
20
|
+
end
|
21
|
+
|
18
22
|
# https://github.com/rails/rails/blob/70ac072976c8cc6f013f0df3777e54ccae3f4f8c/activerecord/lib/active_record/inheritance.rb#L132-L150
|
19
23
|
def compute_class(type_name)
|
20
24
|
parent_name = @parent_class.to_s
|
data/lib/spyke/version.rb
CHANGED
data/test/associations_test.rb
CHANGED
@@ -384,6 +384,11 @@ module Spyke
|
|
384
384
|
assert_equal Cookbook::Favorite, favorite.class
|
385
385
|
end
|
386
386
|
|
387
|
+
def test_specifying_class_outside_of_namespace
|
388
|
+
photo = Cookbook::Tip.new.photos.build
|
389
|
+
assert_equal Photo, photo.class
|
390
|
+
end
|
391
|
+
|
387
392
|
def test_raising_exception_if_class_not_found
|
388
393
|
assert_raises NameError do
|
389
394
|
Cookbook::Tip.new.votes
|
data/test/support/fixtures.rb
CHANGED
@@ -96,6 +96,7 @@ module Cookbook
|
|
96
96
|
has_many :likes, class_name: 'Cookbook::Like', uri: '/tips/:cookbook_tip_id/likes/(:id)'
|
97
97
|
has_many :favorites
|
98
98
|
has_many :votes
|
99
|
+
has_many :photos, class_name: 'Photo'
|
99
100
|
end
|
100
101
|
|
101
102
|
class Like < Spyke::Base
|
@@ -103,4 +104,7 @@ module Cookbook
|
|
103
104
|
|
104
105
|
class Favorite < Spyke::Base
|
105
106
|
end
|
107
|
+
|
108
|
+
class Photo < Spyke::Base
|
109
|
+
end
|
106
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spyke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Balvig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|