spyke 1.8.6 → 1.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21babce7ddc3d045a984d9efc4501ac4b811f497
4
- data.tar.gz: bb6a369931ec88d716aed6fe2831928ac9f42e60
3
+ metadata.gz: 86fba5601363bb57856a5cd3eb2dce1d37d8514e
4
+ data.tar.gz: 0fb9a9ae25540cc72fb6aac4513ed3d601e6412e
5
5
  SHA512:
6
- metadata.gz: c298b3f6569a9a0367129b54b76d3b1ccc042b3ddc0f829c1f0ef279666aaa84e576b3427fc63006cc5cf542ebda1e38a4ce890f6c177a031b4d0a63c3664d3e
7
- data.tar.gz: bfd3b3b44721671a22be2c9732917b495d710a4504d4eccd892c88b81790f1370a4e6f73092f6e3afe9a89ae5a692af2dd50b1ee8dadab3a3d8af9b5e4caddf8
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 ||= compute_class(@options[:class_name] || @name)
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
@@ -1,3 +1,3 @@
1
1
  module Spyke
2
- VERSION = '1.8.6'
2
+ VERSION = '1.8.7'
3
3
  end
@@ -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
@@ -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.6
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-21 00:00:00.000000000 Z
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport