spyke 1.8.2 → 1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spyke/orm.rb +12 -2
- data/lib/spyke/version.rb +1 -1
- data/test/orm_test.rb +5 -1
- data/test/support/fixtures.rb +2 -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: c511b748bec0a2438f2c05d6cd2e76346b55f387
|
4
|
+
data.tar.gz: 67f632949d0fd0429bb3576d84e771c9709f74c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1241be3c296ac93e9bfa523ec598f0f550aa122897a34b2a322f378251d9a943b8a7a07818abab823ffcf686c8aa064f3e46c2b824df5ec4471f81a05e28dc2a
|
7
|
+
data.tar.gz: accfea484c16960b90f02696489ddb98bd02682779c2e6cf4ceae21ee448e430153f07edd32241c36297c93114c94f5780477d314d4ea1a0ff285c06a63ac96a
|
data/lib/spyke/orm.rb
CHANGED
@@ -49,8 +49,8 @@ module Spyke
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def to_params
|
52
|
-
if
|
53
|
-
{
|
52
|
+
if param_root
|
53
|
+
{ param_root => attributes.to_params.except(*uri.variables)}
|
54
54
|
else
|
55
55
|
attributes.to_params.except(*uri.variables)
|
56
56
|
end
|
@@ -81,5 +81,15 @@ module Spyke
|
|
81
81
|
def reload
|
82
82
|
self.attributes = self.class.find(id).attributes
|
83
83
|
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def param_root
|
88
|
+
if include_root.is_a? String
|
89
|
+
include_root
|
90
|
+
elsif include_root?
|
91
|
+
self.class.model_name.param_key
|
92
|
+
end
|
93
|
+
end
|
84
94
|
end
|
85
95
|
end
|
data/lib/spyke/version.rb
CHANGED
data/test/orm_test.rb
CHANGED
@@ -119,10 +119,14 @@ module Spyke
|
|
119
119
|
assert_requested endpoint
|
120
120
|
end
|
121
121
|
|
122
|
-
def
|
122
|
+
def test_to_params_without_root
|
123
123
|
assert_equal({ 'url' => 'bob.jpg' }, RecipeImage.new(url: 'bob.jpg').to_params)
|
124
124
|
end
|
125
125
|
|
126
|
+
def test_to_params_with_custom_root
|
127
|
+
assert_equal({ 'step_image_root' => { 'url' => 'bob.jpg' } }, StepImage.new(url: 'bob.jpg').to_params)
|
128
|
+
end
|
129
|
+
|
126
130
|
def test_destroy
|
127
131
|
endpoint = stub_request(:delete, 'http://sushi.com/recipes/1')
|
128
132
|
Recipe.new(id: 1).destroy
|
data/test/support/fixtures.rb
CHANGED
@@ -37,12 +37,14 @@ class Image < Spyke::Base
|
|
37
37
|
end
|
38
38
|
|
39
39
|
class StepImage < Image
|
40
|
+
include_root_in_json 'step_image_root'
|
40
41
|
end
|
41
42
|
|
42
43
|
class RecipeImage < Image
|
43
44
|
uri '/recipes/:recipe_id/image'
|
44
45
|
validates :url, presence: true
|
45
46
|
attributes :url
|
47
|
+
|
46
48
|
include_root_in_json false
|
47
49
|
end
|
48
50
|
|
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.3
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|