api_client 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,7 +39,7 @@ module ApiClient
39
39
  end
40
40
 
41
41
  def destroy
42
- self.class.destroy(self.id)
42
+ get_scope.destroy(self.id)
43
43
  end
44
44
 
45
45
  def payload
@@ -49,12 +49,15 @@ module ApiClient
49
49
  end
50
50
 
51
51
  def remote_update
52
- scope = original_scope || self.class
53
- scope.update(self.id, payload)
52
+ get_scope.update(self.id, payload)
54
53
  end
55
54
 
56
55
  def remote_create
57
- self.class.create(payload)
56
+ get_scope.create(payload)
57
+ end
58
+
59
+ def get_scope
60
+ original_scope || self.class
58
61
  end
59
62
 
60
63
  end
@@ -1,3 +1,3 @@
1
1
  module ApiClient
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -53,6 +53,12 @@ describe ApiClient::Resource::Base do
53
53
  @instance.destroy
54
54
  end
55
55
 
56
+ it "retains the original scope" do
57
+ @instance.original_scope = stub
58
+ @instance.original_scope.should_receive(:destroy).with(42)
59
+ @instance.destroy
60
+ end
61
+
56
62
  end
57
63
 
58
64
  describe "#remote_update" do
@@ -78,6 +84,12 @@ describe ApiClient::Resource::Base do
78
84
  @instance.remote_create
79
85
  end
80
86
 
87
+ it "retains the original scope" do
88
+ @instance.original_scope = stub
89
+ @instance.original_scope.should_receive(:create).with("name" => "Mike")
90
+ @instance.remote_create
91
+ end
92
+
81
93
  end
82
94
 
83
95
  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.3.0
4
+ version: 0.3.1
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-13 00:00:00.000000000 Z
12
+ date: 2012-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday