Skip to content
Browse files

Merge pull request #8846 from AlexRiedler/revert_5861

Backport multi_json dependency revert of #5861 to 3-1-stable
  • Loading branch information...
2 parents a97199d + 7b9bab6 commit b816e8e76ee76f750effe3bf7640faaba4f1a8a8 @rafaelfranca rafaelfranca committed Jan 9, 2013
View
6 activesupport/CHANGELOG.md
@@ -1,3 +1,9 @@
+## Rails 3.1.11 ##
+
+* Allow multi_json version >= 1.3, relaxing
+ back to semantic versioning 2.0.0 (revert of #5861)
+ Backport of #5896
+
## Rails 3.1.10 (Jan 8, 2012) ##
* Hash.from_xml raises when it encounters type="symbol" or type="yaml".
View
2 activesupport/activesupport.gemspec
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
s.rdoc_options.concat ['--encoding', 'UTF-8']
- s.add_dependency('multi_json', '>= 1.0', '< 1.3')
+ s.add_dependency('multi_json', '~> 1.0')
end
View
20 activesupport/lib/active_support/json/decoding.rb
@@ -9,7 +9,13 @@ module ActiveSupport
module JSON
class << self
def decode(json, options ={})
- data = MultiJson.decode(json, options)
+ # Can't reliably detect whether MultiJson responds to load, since it's
+ # a reserved word. Use adapter as a proxy for new features.
+ data = if MultiJson.respond_to?(:adapter)
+ MultiJson.load(json, options)
+ else
+ MultiJson.decode(json, options)
+ end
if ActiveSupport.parse_json_times
convert_dates_from(data)
else
@@ -18,12 +24,20 @@ def decode(json, options ={})
end
def engine
- MultiJson.engine
+ if MultiJson.respond_to?(:adapter)
+ MultiJson.adapter
+ else
+ MultiJson.engine
+ end
end
alias :backend :engine
def engine=(name)
- MultiJson.engine = name
+ if MultiJson.respond_to?(:use)
+ MultiJson.use name
+ else
+ MultiJson.engine = name
+ end
end
alias :backend= :engine=

0 comments on commit b816e8e

Please sign in to comment.
Something went wrong with that request. Please try again.