chain 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 96a912a49313f8b3e5f4f384c4b85e421c7950fb
4
- data.tar.gz: 95bf5be6688445559aa4d5afa0144e9d7ce1f2a8
3
+ metadata.gz: 78f46a473a0b2ca4c82513bb2d4e492cb6e85c46
4
+ data.tar.gz: ef312f8a83617ba52da44b9f304298c68306932a
5
5
  SHA512:
6
- metadata.gz: 0bf5415f4bd29a8d98a1a31e2077f76d3ff3959dfeeafdd826ef1df002d7e7e9d99cadeeaa2bc095038bc80d0e2b27b1735b5ceb732b4fb83b9f0b88b3df74c6
7
- data.tar.gz: f6f9e422551146b173d85f60383b8e1bea9a298b7ad84c7ddbf564f478a31987c60337ed7d98a1414aebacd1beec362577938a3059b5f5f593bee07b84b2f01c
6
+ metadata.gz: 36763e8dc1cdf79e8fec74b121b0344412bd9465cc5941264f35888d82b7883421550676e8cc2ee23eb38814c90badaaa4fda4245e318306c2e2ef334dbe6b8f
7
+ data.tar.gz: 9d04368dacab30f6ca15eaa377599fa6e158e41a724facda1adaf356ba3dbf9fe5f560b8624729a4550e95a48eccdf9fa0bdd61b1359589bed1ddc41ebd2e127
@@ -37,6 +37,9 @@ module Chain
37
37
  end
38
38
 
39
39
  def method_missing(method_name, path=nil, params={}, &block)
40
+ if path.is_a? Hash
41
+ path, params = nil, path.merge(params)
42
+ end
40
43
 
41
44
  # If this is a bang method, prepare to run a _fetch.
42
45
  is_bang_method = method_name.to_s.chars.last == "!"
@@ -47,7 +50,10 @@ module Chain
47
50
  # should call into #{base}/api/items/My%20Item?f=json
48
51
  combined_path = [method_name, path].compact.join("/")
49
52
 
50
- url = URI.join("#{@url}/", combined_path)
53
+ # If the combined_path is empty (i.e., we're just evaluating parameters from bracket
54
+ # notation), then we're just going to reuse the url Otherwise, assume that combined_path
55
+ # appends onto the path.
56
+ url = combined_path.empty? ? @url : URI.join("#{@url}/", combined_path)
51
57
 
52
58
  self.class.new(url, @base_url || self, params, &block).tap do |request|
53
59
  return request._fetch(params, &block) if is_bang_method || !params.empty?
@@ -59,8 +65,7 @@ module Chain
59
65
  path, params = nil, path.merge(params)
60
66
  end
61
67
 
62
- url = [@url, path].compact.join("/")
63
- method_missing(url, nil, **params)
68
+ method_missing(nil, path, **params)
64
69
  end
65
70
 
66
71
  def _fetch(params={}, &block)
@@ -1,3 +1,3 @@
1
1
  module Chain
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Novak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-16 00:00:00.000000000 Z
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler