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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6779fa06becdb47897220855b4e40d59658023f1
4
- data.tar.gz: 3cfe8b3ee6430491574925643cbfeee651e1da91
3
+ metadata.gz: c511b748bec0a2438f2c05d6cd2e76346b55f387
4
+ data.tar.gz: 67f632949d0fd0429bb3576d84e771c9709f74c8
5
5
  SHA512:
6
- metadata.gz: c272d4e8115b633f5946c95085096a79deef8a1b5a64aa790af8bb3d066397bc9bdef99d4ac2a9be9ed1a3f3eccb6bac6692f196ed8c28ae68b3dcd9576c0994
7
- data.tar.gz: 4fe79e4c7c0b0c5a7e2c9dcdb8267e12c8b93bcf59dc417176f2aea9e4cf0dcadd490939c6002a5d62460ead053fc6c549682c29fe64b7ae85afd720b2e7dd9b
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 include_root?
53
- { self.class.model_name.param_key => attributes.to_params.except(*uri.variables)}
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
@@ -1,3 +1,3 @@
1
1
  module Spyke
2
- VERSION = '1.8.2'
2
+ VERSION = '1.8.3'
3
3
  end
data/test/orm_test.rb CHANGED
@@ -119,10 +119,14 @@ module Spyke
119
119
  assert_requested endpoint
120
120
  end
121
121
 
122
- def test_non_nested_params
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
@@ -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.2
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-04 00:00:00.000000000 Z
11
+ date: 2015-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport