api_gears 1.0.3 → 1.0.4

This diff has not been reviewed by any users.
Log in in order to be able to vote.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/api_gears.rb +7 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 548bb48ccb9ac58a7b7ffaeb721c6555a2277def81c9760d72a15a94d815a834
4
- data.tar.gz: b47a91c3db56462aaed913aa3d0f35f69691e4683bca4c7c9f52f3002b244a7e
3
+ metadata.gz: 0f507faa2482f5d973b16cccbd1e571f3475251cd2bd905cccc3e56557c4eeb1
4
+ data.tar.gz: 16052d258d0e726758d00185999c6063b4ef9e05440406cdc4ff24d74714c9cc
5
5
  SHA512:
6
- metadata.gz: 7a7edbbf6e91f9c3487af26ee57f27a4e219dd80a000ff7295b2117e7c1579f7e5c832a044e695b252269cfcb060c420db73e6ae63ff85fb4592c78fdc4fe53d
7
- data.tar.gz: 60b35d6156a5af96defb2e2dea720aa72e16dfccf2b84a5a14271917a373b82ee1bea856afcca36485f619e4af3afa90ed9450b1e8f1daac9371dff222ac9e3e
6
+ metadata.gz: 053a41ef2a760d158b8130b775357b32642b25e0bf5b5a61cb8c8dfc70f55b6925d3ce9af3e91b8e2238eb7013269f6059df87fb81e372535bd354c2d2b4216c
7
+ data.tar.gz: d48f6cfd3fb8e7a6d58d9917309bfaced0f51352269a37560d505b986ca5f48d20386753b53e8e2bb405c6f77d1a0930ad4da53dd6943e1eb6775a64fb2be40f
@@ -214,7 +214,7 @@ class ApiGears
214
214
  end
215
215
  # Builds URL and args for a specific endpoint call
216
216
  # @param endpoint [String] or [Symbol] the method name that has been called
217
- # @param args [Hash] the args passed in during the method call
217
+ # @param args [Hash] the args passed in during the method call, when the required arg has 2 parts, (eg "book_id"), the first part of the arg name can be used (in this case "book" though this should only be used when "book" is unique in the query)
218
218
  # @return [Hash] with url and query params
219
219
  def url_for(endpoint, args)
220
220
  url = @uri.dup
@@ -223,12 +223,15 @@ class ApiGears
223
223
 
224
224
  if(!@endpoints[endpoint.to_sym][:args].nil? && @endpoints[endpoint.to_sym][:args].length > 0)
225
225
  args_for(endpoint.to_sym).each do |arg|
226
- if(!args[arg].nil? && arg.to_s.split("_").length == 2 && args[arg.to_s.split("_")[0].to_sym].nil?)
226
+ specific_arg_not_found = (args[arg].nil?)
227
+ arg_has_two_parts = (arg.to_s.split("_").length == 2)
228
+ arg_shortcut_found = (!args[arg.to_s.split("_")[0].to_sym].nil?)
229
+ if(specific_arg_not_found && arg_has_two_parts && arg_shortcut_found )
227
230
  value = args[arg.to_s.split("_")[0].to_sym]
228
231
  else
229
232
  value = args[arg]
230
233
  end
231
- e_path = e_path.gsub("{#{arg}}", value.to_s)
234
+ e_path = e_path.gsub("{#{arg.to_s}}", value.to_s)
232
235
  end
233
236
  end
234
237
 
@@ -249,6 +252,7 @@ class ApiGears
249
252
  end
250
253
  end
251
254
 
255
+
252
256
  if(args[:query_method] == :GET)
253
257
  url.query = URI.encode_www_form(query_set)
254
258
  return {url:url,params:{}}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_gears
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Mikeska