active_rest_client 1.0.1 → 1.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b673b275ac742495303d8632a70e7a2425df69bf
|
4
|
+
data.tar.gz: 99edc9e4f9ec9faa7703449685c48b898196ee15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea15068289c7bedc5faee76611548e342e8ba395f4bb76fb81f99395d5f3fad10e0936a94df5eac5c45236adf137b9ade25c7553a7828c44ad4e83d2d23be3e9
|
7
|
+
data.tar.gz: d201d14a7563791a12885ffb7967f58c938194cd979d06c779b42db11cb0792f336d6f7993ad1e21cd8985cfddc05ff8f4522d098b9b5d733f6ba8c62c41af25
|
data/active_rest_client.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
23
|
spec.add_development_dependency "rake"
|
24
|
-
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rspec", "~> 2"
|
25
25
|
spec.add_development_dependency "webmock"
|
26
26
|
spec.add_development_dependency "rspec_junit_formatter"
|
27
27
|
spec.add_development_dependency "simplecov"
|
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_runtime_dependency "multi_json"
|
34
34
|
spec.add_runtime_dependency "activesupport"
|
35
35
|
spec.add_runtime_dependency "faraday", "~> 0.9"
|
36
|
-
spec.
|
36
|
+
spec.add_development_dependency "patron", ">= 0.4.9" # 0.4.18 breaks against Curl v0.7.15 but works with webmock
|
37
37
|
end
|
@@ -6,7 +6,8 @@ module ActiveRestClient
|
|
6
6
|
|
7
7
|
def initialize(name, value, request, options = {})
|
8
8
|
@name = name
|
9
|
-
|
9
|
+
class_to_map = request.method[:options][:lazy][name] rescue nil
|
10
|
+
@request = class_to_map.nil? ? request : ActiveRestClient::Request.new(class_to_map._mapped_method(:find), class_to_map.new, options)
|
10
11
|
@object = nil
|
11
12
|
@options = options
|
12
13
|
if value.is_a? Array
|
@@ -1,5 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
class MonthExample < ActiveRestClient::Base
|
4
|
+
base_url "http://www.example.com"
|
5
|
+
|
6
|
+
get :find, "/month/:id", fake:"{\"name\":\"january\"}"
|
7
|
+
end
|
8
|
+
|
9
|
+
class YearExample < ActiveRestClient::Base
|
10
|
+
base_url "http://www.example.com"
|
11
|
+
|
12
|
+
get :find, "/year/:id", lazy: { months: MonthExample }, fake: "{\"months\": [\"http://www.example.com/months/1\"] }"
|
13
|
+
end
|
14
|
+
|
3
15
|
describe ActiveRestClient::LazyAssociationLoader do
|
4
16
|
let(:url1) { "http://www.example.com/some/url" }
|
5
17
|
let(:url2) { "http://www.example.com/some/other" }
|
@@ -115,4 +127,9 @@ describe ActiveRestClient::LazyAssociationLoader do
|
|
115
127
|
ActiveRestClient::Request.any_instance.should_receive(:call).with(any_args).and_return([1,2,3])
|
116
128
|
expect(loader.size).to eq(3)
|
117
129
|
end
|
130
|
+
|
131
|
+
it "should use the class specified in the 'lazy' declaration to parse the response rather than the class of the object the lazy loader is attached to" do
|
132
|
+
association = YearExample.find(1)
|
133
|
+
expect(association.months.instance_variable_get('@request').instance_variable_get('@object').class).to eq(MonthExample)
|
134
|
+
end
|
118
135
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_rest_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Which Ltd
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,16 +43,16 @@ dependencies:
|
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '2'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '2'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: webmock
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,7 +200,7 @@ dependencies:
|
|
200
200
|
- - ">="
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: 0.4.9
|
203
|
-
type: :
|
203
|
+
type: :development
|
204
204
|
prerelease: false
|
205
205
|
version_requirements: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|