clientele 0.3.4 → 0.3.5
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 +11 -1
- 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: bf35f41aec66613763efd57e96b0133aa1575c09
|
4
|
+
data.tar.gz: 5a18a2f492750d10f0a70eb28cf5632a8ebf575b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 879994c740dc32c41dfc00a4f5c0273f949412c24b3bbe08da3fb54d972b3a3a74472838e1f9a13cd1196863200cec98a2d289ae6d06d4e6e8abb69be61c9230
|
7
|
+
data.tar.gz: f338fb9aea534ca80aaa322859d7bd7c749424c01d7bbd831eb81472cf802b0c4501c4875d24e3f4f6b6ca57d5f235d26fac01da94b4e42c386b5c9c02c53a48
|
data/lib/clientele/resource.rb
CHANGED
@@ -51,13 +51,21 @@ module Clientele
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def result_key
|
54
|
-
@result_key || method_name
|
54
|
+
@result_key || method_name.singularize
|
55
|
+
end
|
56
|
+
|
57
|
+
def plural_key
|
58
|
+
@plural_key || method_name
|
55
59
|
end
|
56
60
|
|
57
61
|
def nested_result_key
|
58
62
|
@nested_result_key || result_key
|
59
63
|
end
|
60
64
|
|
65
|
+
def nested_plural_key
|
66
|
+
@nested_plural_key || plural_key
|
67
|
+
end
|
68
|
+
|
61
69
|
def build(data, client: nil, klass: nil)
|
62
70
|
case (klass or data).kind_of? Array
|
63
71
|
data.map do |dataset|
|
@@ -65,6 +73,8 @@ module Clientele
|
|
65
73
|
end
|
66
74
|
elsif (klass or data).kind_of? Hash and data.keys.map(&:to_s).include? result_key.to_s
|
67
75
|
build data.send method_name, client: client
|
76
|
+
elsif (klass or data).kind_of? Hash and data.keys.map(&:to_s).include? plural_key.to_s
|
77
|
+
build data.send method_name, client: client
|
68
78
|
else
|
69
79
|
new(data).tap do |instance|
|
70
80
|
instance.instance_variable_set :@client, client if client
|
data/lib/clientele/version.rb
CHANGED