diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2012-04-21 12:15:39 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2012-04-21 12:15:39 -0700 |
commit | c3d50b35b0e03a68095ebb0d52d371d28c8aa436 (patch) | |
tree | 9289c59ed6f0a7f85b4973841fce53d91f2b72a9 /activesupport | |
parent | f51557deb0a591a442e94d07d90e57853693ad14 (diff) | |
parent | 5e62670131dfa1718eaf21ff8dd3371395a5f1cc (diff) | |
download | rails-c3d50b35b0e03a68095ebb0d52d371d28c8aa436.tar.gz rails-c3d50b35b0e03a68095ebb0d52d371d28c8aa436.tar.bz2 rails-c3d50b35b0e03a68095ebb0d52d371d28c8aa436.zip |
Merge pull request #5896 from sferik/revert_5861
Revert #5861. Feature-detect which MultiJson API to use.
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/activesupport.gemspec | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/json/decoding.rb | 20 |
2 files changed, 18 insertions, 4 deletions
diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index 696f2ca803..e6fc7bf571 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -19,5 +19,5 @@ Gem::Specification.new do |s| s.rdoc_options.concat ['--encoding', 'UTF-8'] s.add_dependency('i18n', '~> 0.6') - s.add_dependency('multi_json', '>= 1.0', '< 1.3') + s.add_dependency('multi_json', '~> 1.0') end diff --git a/activesupport/lib/active_support/json/decoding.rb b/activesupport/lib/active_support/json/decoding.rb index cbeb6c0a28..f95eb7a289 100644 --- a/activesupport/lib/active_support/json/decoding.rb +++ b/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 @@ module ActiveSupport 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= |