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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6582c99553295f93676db28a306f47c12a618c24
4
- data.tar.gz: 981a484ad7dda1988ec60df5a2cd1c6a1f82d992
3
+ metadata.gz: 8207fdcdcd84032d25d8326f164adfe78c1127d3
4
+ data.tar.gz: 49fef12babfe85a269d5bfda4189c9b6e9c51374
5
5
  SHA512:
6
- metadata.gz: f63be792b186af675a00945ff1e999813dfabfd4e8c6bbcf09a98f901b2ae8081971061a4da5adb29f74fd6764c0d58c445048ae062c7c9db78b534d4eba1f94
7
- data.tar.gz: 7524c40b6373d57b3745e423f5fd9afead437495fab9d5356b580b33c54a80a6a445358caca7df0b2dafac32303f683b80c12a676847a6125db131f9c0983767
6
+ metadata.gz: ec6d1576db4412c82976bd30215b56b51a490dee08721f09beb7c153999fb10445c3351f7d27033a9f35548ff9f276b145eb648c0b0cc582a4be94f69416a715
7
+ data.tar.gz: 0a2d471117284e00096927c40532810cd1de570a28f390fd5db659756386ebca15299b045fe768533dc6c100c34e00542673fd3c5ffb38e525c3c85e15d9aa20
@@ -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 plural_key
58
- @plural_key || method_name
57
+ def result(data)
58
+ data[result_key]
59
59
  end
60
60
 
61
- def nested_result_key
62
- @nested_result_key || result_key
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.keys.map(&:to_s).include? plural_key.to_s
78
- build data.fetch(plural_key), client: client, response: response
79
- elsif data.keys.map(&:to_s).include? result_key.to_s
80
- throw :build, data.fetch(result_key)
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, response: response
78
+ build dataset, client: client#, response: response
87
79
  end
88
80
  end
89
81
  end
@@ -1,3 +1,3 @@
1
1
  module Clientele
2
- VERSION = "0.3.10"
2
+ VERSION = "0.3.11"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clientele
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Keele