Update to Rails 2.3.8

This commit is contained in:
Jacques Distler 2010-05-25 12:45:45 -05:00
parent 6677b46cb4
commit f0635301aa
429 changed files with 17683 additions and 4047 deletions

View file

@ -227,6 +227,9 @@ module ActiveResource
# The logger for diagnosing and tracing Active Resource calls.
cattr_accessor :logger
# Controls the top-level behavior of JSON serialization
cattr_accessor :include_root_in_json, :instance_writer => false
class << self
# Gets the URI of the REST resources to map for this class. The site variable is required for
# Active Resource's mapping to work.
@ -431,11 +434,11 @@ module ActiveResource
@prefix_parameters = nil
# Redefine the new methods.
code = <<-end_code
code, line = <<-end_code, __LINE__ + 1
def prefix_source() "#{value}" end
def prefix(options={}) "#{prefix_call}" end
end_code
silence_warnings { instance_eval code, __FILE__, __LINE__ }
silence_warnings { instance_eval code, __FILE__, line }
rescue
logger.error "Couldn't set prefix: #{$!}\n #{code}"
raise
@ -971,6 +974,12 @@ module ActiveResource
case self.class.format
when ActiveResource::Formats[:xml]
self.class.format.encode(attributes, {:root => self.class.element_name}.merge(options))
when ActiveResource::Formats::JsonFormat
if ActiveResource::Base.include_root_in_json
self.class.format.encode({self.class.element_name => attributes}, options)
else
self.class.format.encode(attributes, options)
end
else
self.class.format.encode(attributes, options)
end

View file

@ -57,7 +57,7 @@ module ActiveResource
# def post(path, request_headers = {}, body = nil, status = 200, response_headers = {})
# @responses[Request.new(:post, path, nil, request_headers)] = Response.new(body || "", status, response_headers)
# end
module_eval <<-EOE, __FILE__, __LINE__
module_eval <<-EOE, __FILE__, __LINE__ + 1
def #{method}(path, request_headers = {}, body = nil, status = 200, response_headers = {})
@responses << [Request.new(:#{method}, path, nil, request_headers), Response.new(body || "", status, response_headers)]
end
@ -125,7 +125,7 @@ module ActiveResource
# self.class.requests << request
# self.class.responses.assoc(request).try(:second) || raise(InvalidRequestError.new("No response recorded for #{request}"))
# end
module_eval <<-EOE, __FILE__, __LINE__
module_eval <<-EOE, __FILE__, __LINE__ + 1
def #{method}(path, #{'body, ' if has_body}headers)
request = ActiveResource::Request.new(:#{method}, path, #{has_body ? 'body, ' : 'nil, '}headers)
self.class.requests << request

View file

@ -259,10 +259,10 @@ module ActiveResource
save_without_validation
true
rescue ResourceInvalid => error
case error.response['Content-Type']
when /xml/
case self.class.format
when ActiveResource::Formats[:xml]
errors.from_xml(error.response.body)
when /json/
when ActiveResource::Formats[:json]
errors.from_json(error.response.body)
end
false

View file

@ -2,7 +2,7 @@ module ActiveResource
module VERSION #:nodoc:
MAJOR = 2
MINOR = 3
TINY = 5
TINY = 8
STRING = [MAJOR, MINOR, TINY].join('.')
end