activeresource 3.0.0.beta2 → 3.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activeresource might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ *Rails 3.0.0 [beta 3] (April 13th, 2010)*
2
+
3
+ * No changes
4
+
5
+
1
6
  *Rails 3.0.0 [beta 1] (February 4, 2010)*
2
7
 
3
8
  * Add support for errors in JSON format. #1956 [Fabien Jakimowicz]
@@ -251,6 +251,9 @@ module ActiveResource
251
251
  # The logger for diagnosing and tracing Active Resource calls.
252
252
  cattr_accessor :logger
253
253
 
254
+ # Controls the top-level behavior of JSON serialization
255
+ cattr_accessor :include_root_in_json, :instance_writer => false
256
+
254
257
  class << self
255
258
  # Creates a schema for this resource - setting the attributes that are
256
259
  # known prior to fetching an instance from the remote system.
@@ -585,11 +588,11 @@ module ActiveResource
585
588
  @prefix_parameters = nil
586
589
 
587
590
  # Redefine the new methods.
588
- code = <<-end_code
591
+ code, line = <<-end_code, __LINE__ + 1
589
592
  def prefix_source() "#{value}" end
590
593
  def prefix(options={}) "#{prefix_call}" end
591
594
  end_code
592
- silence_warnings { instance_eval code, __FILE__, __LINE__ }
595
+ silence_warnings { instance_eval code, __FILE__, line }
593
596
  rescue
594
597
  logger.error "Couldn't set prefix: #{$!}\n #{code}" if logger
595
598
  raise
@@ -1240,6 +1243,12 @@ module ActiveResource
1240
1243
  case self.class.format
1241
1244
  when ActiveResource::Formats::XmlFormat
1242
1245
  self.class.format.encode(attributes, {:root => self.class.element_name}.merge(options))
1246
+ when ActiveResource::Formats::JsonFormat
1247
+ if ActiveResource::Base.include_root_in_json
1248
+ self.class.format.encode({self.class.element_name => attributes}, options)
1249
+ else
1250
+ self.class.format.encode(attributes, options)
1251
+ end
1243
1252
  else
1244
1253
  self.class.format.encode(attributes, options)
1245
1254
  end
@@ -57,7 +57,7 @@ module ActiveResource
57
57
  # def post(path, request_headers = {}, body = nil, status = 200, response_headers = {})
58
58
  # @responses[Request.new(:post, path, nil, request_headers)] = Response.new(body || "", status, response_headers)
59
59
  # end
60
- module_eval <<-EOE, __FILE__, __LINE__
60
+ module_eval <<-EOE, __FILE__, __LINE__ + 1
61
61
  def #{method}(path, request_headers = {}, body = nil, status = 200, response_headers = {})
62
62
  @responses << [Request.new(:#{method}, path, nil, request_headers), Response.new(body || "", status, response_headers)]
63
63
  end
@@ -125,7 +125,7 @@ module ActiveResource
125
125
  # self.class.requests << request
126
126
  # self.class.responses.assoc(request).try(:second) || raise(InvalidRequestError.new("No response recorded for #{request}"))
127
127
  # end
128
- module_eval <<-EOE, __FILE__, __LINE__
128
+ module_eval <<-EOE, __FILE__, __LINE__ + 1
129
129
  def #{method}(path, #{'body, ' if has_body}headers)
130
130
  request = ActiveResource::Request.new(:#{method}, path, #{has_body ? 'body, ' : 'nil, '}headers)
131
131
  self.class.requests << request
@@ -3,7 +3,7 @@ module ActiveResource
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
5
  TINY = 0
6
- BUILD = "beta2"
6
+ BUILD = "beta3"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].join('.')
9
9
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 3
7
7
  - 0
8
8
  - 0
9
- - beta2
10
- version: 3.0.0.beta2
9
+ - beta3
10
+ version: 3.0.0.beta3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Heinemeier Hansson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-01 00:00:00 -07:00
18
+ date: 2010-04-13 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -29,8 +29,8 @@ dependencies:
29
29
  - 3
30
30
  - 0
31
31
  - 0
32
- - beta2
33
- version: 3.0.0.beta2
32
+ - beta3
33
+ version: 3.0.0.beta3
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
@@ -44,8 +44,8 @@ dependencies:
44
44
  - 3
45
45
  - 0
46
46
  - 0
47
- - beta2
48
- version: 3.0.0.beta2
47
+ - beta3
48
+ version: 3.0.0.beta3
49
49
  type: :runtime
50
50
  version_requirements: *id002
51
51
  description: REST on Rails. Wrap your RESTful web app with Ruby classes and work with them like Active Record models.