clientele 0.3.10 → 0.3.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/clientele/resource.rb +10 -18
- data/lib/clientele/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8207fdcdcd84032d25d8326f164adfe78c1127d3
|
4
|
+
data.tar.gz: 49fef12babfe85a269d5bfda4189c9b6e9c51374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec6d1576db4412c82976bd30215b56b51a490dee08721f09beb7c153999fb10445c3351f7d27033a9f35548ff9f276b145eb648c0b0cc582a4be94f69416a715
|
7
|
+
data.tar.gz: 0a2d471117284e00096927c40532810cd1de570a28f390fd5db659756386ebca15299b045fe768533dc6c100c34e00542673fd3c5ffb38e525c3c85e15d9aa20
|
data/lib/clientele/resource.rb
CHANGED
@@ -51,39 +51,31 @@ module Clientele
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def result_key
|
54
|
-
@result_key || method_name.singularize
|
54
|
+
@result_key || method_name.to_s.singularize
|
55
55
|
end
|
56
56
|
|
57
|
-
def
|
58
|
-
|
57
|
+
def result(data)
|
58
|
+
data[result_key]
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
def nested_plural_key
|
66
|
-
@nested_plural_key || plural_key
|
67
|
-
end
|
68
|
-
|
69
|
-
def nested_plural_key
|
70
|
-
@nested_plural_key || plural_key
|
61
|
+
def results(data)
|
62
|
+
result(data) if result(data) and result(data).kind_of?(Array)
|
71
63
|
end
|
72
64
|
|
73
65
|
def build(data, client: nil, response: nil)
|
74
66
|
new(
|
75
67
|
catch(:build) do
|
76
68
|
if data.kind_of? Hash
|
77
|
-
if data
|
78
|
-
build
|
79
|
-
elsif data
|
80
|
-
throw :build,
|
69
|
+
if many = results(data)
|
70
|
+
build many, client: client#, response: response
|
71
|
+
elsif one = result(data)
|
72
|
+
throw :build, one
|
81
73
|
else
|
82
74
|
throw :build, data
|
83
75
|
end
|
84
76
|
elsif data.respond_to? :map
|
85
77
|
data.map do |dataset|
|
86
|
-
build dataset, client: client
|
78
|
+
build dataset, client: client#, response: response
|
87
79
|
end
|
88
80
|
end
|
89
81
|
end
|
data/lib/clientele/version.rb
CHANGED