rest_resource 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -14,17 +14,21 @@ Given you need to fetch user from a web service. You can write:
14
14
 
15
15
  class User < RestResource::Resource
16
16
  class << self
17
- def url
18
- "http://www.example.com/users"
17
+ def site
18
+ "http://www.example.com"
19
+ end
20
+
21
+ def resource_name
22
+ "resources"
19
23
  end
20
24
  end
21
25
  end
22
26
 
23
27
  To use it, you can just do:
24
28
 
25
- User.find 1
29
+ user = User.find 1
26
30
 
27
- User.create :name => "Leslie Cheung", :login => "singer"
31
+ user = User.create :name => "Leslie Cheung", :login => "singer"
28
32
 
29
33
  Both operation assume your web service controller returns a json string which can be initialized into an object.
30
34
 
@@ -14,6 +14,10 @@ module RestResource
14
14
 
15
15
  private
16
16
 
17
+ def url
18
+ "#{site}/#{resource_name}"
19
+ end
20
+
17
21
  def rest_crud
18
22
  RestCrud.new(url)
19
23
  end
@@ -1,3 +1,3 @@
1
1
  module RestResource
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -6,9 +6,14 @@ module RestResource
6
6
  let(:create_params) {{"attr1" => "val1"}}
7
7
  let(:klass) {
8
8
  Class.new(Resource) do
9
- def self.url
10
- "http://www.example.com/resources"
9
+ def self.site
10
+ "http://www.example.com"
11
11
  end
12
+
13
+ def self.resource_name
14
+ "resources"
15
+ end
16
+
12
17
  end
13
18
  }
14
19
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_resource
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yi Wen