rightresource 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. data/lib/right_resource/base.rb +25 -3
  2. metadata +4 -4
@@ -11,7 +11,11 @@ module RightResource
11
11
  end
12
12
 
13
13
  def logger
14
- @logger ||= Logger.new(STDERR).tap {|l| l.level = Logger::WARN}
14
+ if defined?(@logger) || superclass == Object
15
+ @logger ||= Logger.new(STDERR).tap {|l| l.level = Logger::WARN}
16
+ else
17
+ superclass.logger
18
+ end
15
19
  end
16
20
 
17
21
  # Set RESTFul client with login authentication for HTTP Methods(Low level)
@@ -19,7 +23,12 @@ module RightResource
19
23
  # conn = Connection.new do |c|
20
24
  # c.login(:username => "user", :password => "pass", :account => "1")
21
25
  # end
22
- # Server.connection = conn
26
+ # Deployment.connection = conn
27
+ # Deployment.show(1) # => GET /api/acct/1/deployments/1.json
28
+ #
29
+ # RightResource::Base.connction = conn
30
+ # Ec2EbsVolume.show(1) # => GET /api/acct/1/ec2_ebs_volumes/1.json
31
+ # Server.index
23
32
  def connection=(conn)
24
33
  @connection = conn
25
34
  end
@@ -31,7 +40,7 @@ module RightResource
31
40
  # conn.get("servers?filter=nickname=server1")
32
41
  #
33
42
  # ex. resource api call:
34
- # Server.index
43
+ # Server.index # => GET /api/acct/1/servers.json
35
44
  def connection
36
45
  if defined?(@connection) || superclass == Object
37
46
  raise ArgumentError, "Not set connection object!!" unless @connection
@@ -41,6 +50,19 @@ module RightResource
41
50
  end
42
51
  end
43
52
 
53
+ # Sets the format that attributes are sent and received in from a mime type reference:
54
+ #
55
+ # === Examples
56
+ # Server.format = RightResource::Formats::JsonFormat
57
+ # Server.show(1) # => GET /api/acct/1/servers/1.json
58
+ #
59
+ # RightResource::Base.format = RightResource::Formats::JsonFormat
60
+ # Server.index # => GET /api/acct/1/servers.json
61
+ # Ec2EbsVolume.index # => GET /api/acct/1/ec2_ebs_volumes.json
62
+ def format=(mime_type_reference_or_format)
63
+ connection.format = mime_type_reference_or_format
64
+ end
65
+
44
66
  # Get request and response format type object
45
67
  def format
46
68
  connection.format || RightResource::Formats::JsonFormat
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rightresource
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Satoshi Ohki
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-09 00:00:00 +09:00
18
+ date: 2010-11-10 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency