api_client 0.1.9 → 0.2.0

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.
@@ -1,9 +1,6 @@
1
1
  module ApiClient
2
-
3
2
  module Mixins
4
-
5
3
  module Instantiation
6
-
7
4
  def self.extended(base)
8
5
  base.instance_eval do
9
6
  attr_accessor :original_scope
@@ -12,7 +9,7 @@ module ApiClient
12
9
 
13
10
  def build_one(hash)
14
11
  instance = self.new self.namespace ? hash[namespace] : hash
15
- instance.original_scope = self.scope
12
+ instance.original_scope = self.scope.clone_only_headers
16
13
  instance
17
14
  end
18
15
 
@@ -27,9 +24,6 @@ module ApiClient
27
24
  build_one result_or_array
28
25
  end
29
26
  end
30
-
31
27
  end
32
-
33
28
  end
34
-
35
29
  end
@@ -61,6 +61,10 @@ module ApiClient
61
61
  self
62
62
  end
63
63
 
64
+ def clone_only_headers
65
+ self.class.new(self.scopeable).headers(self.headers)
66
+ end
67
+
64
68
  # Half-level :)
65
69
  # This is a swiss-army knife kind of method, extremely useful
66
70
  def fetch(path, options = {})
@@ -72,6 +76,8 @@ module ApiClient
72
76
  # Low-level connection methods
73
77
 
74
78
  def request(method, path, options = {})
79
+ options = options.dup
80
+
75
81
  raw = raw? || options.delete(:raw)
76
82
  params(options)
77
83
  response = connection.send method, path, @params, @headers
@@ -1,3 +1,3 @@
1
1
  module ApiClient
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -42,13 +42,14 @@ describe ApiClient::Base do
42
42
  describe "original_scope" do
43
43
 
44
44
  it "holds the original scope it was created from" do
45
+ scope = ApiClient::Base.params(:foo => 1).headers('token' => 'aaa').options("some" => "option")
45
46
 
46
- scope = ApiClient::Base.params(:foo => 1).headers('token' => 'aaa')
47
47
  instance = scope.build :key => 'value'
48
- instance.original_scope.should == scope
49
-
48
+ instance.original_scope.headers.should == {'token' => 'aaa'}
49
+ instance.original_scope.params.should be_empty
50
+ instance.original_scope.options.should be_empty
50
51
  end
51
52
 
52
53
  end
53
54
 
54
- end
55
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-06 00:00:00.000000000 Z
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project: api_client
140
- rubygems_version: 1.8.24
140
+ rubygems_version: 1.8.21
141
141
  signing_key:
142
142
  specification_version: 3
143
143
  summary: API client builder