diff options
author | rick <technoweenie@gmail.com> | 2009-04-23 00:08:40 -0700 |
---|---|---|
committer | rick <technoweenie@gmail.com> | 2009-04-23 00:08:40 -0700 |
commit | 3c4c6bd0df598f865f49a983b4c65c415af4bcfc (patch) | |
tree | 0984e610d94f22dfa70e95259f1a81e57e7f9db7 /activesupport/lib/active_support/time_with_zone.rb | |
parent | bab2bfa69220ca1b6c7b56dccc79cf8e41245306 (diff) | |
download | rails-3c4c6bd0df598f865f49a983b4c65c415af4bcfc.tar.gz rails-3c4c6bd0df598f865f49a983b4c65c415af4bcfc.tar.bz2 rails-3c4c6bd0df598f865f49a983b4c65c415af4bcfc.zip |
* Add pluggable JSON backends with support for the JSON gem. [rick]
Example: ActiveSupport::JSON.backend = "JSONGem"
All internal Rails JSON encoding is now handled by ActiveSupport::JSON.encode(). Use of #to_json is not recommended, as it may clash with other libraries that overwrite it. However, you can recover Rails specific functionality
if you really want to use #to_json.
gem 'json'
ActiveSupport::JSON.backend = "JSONGem"
class ActiveRecord::Base
alias to_json rails_to_json
end
Diffstat (limited to 'activesupport/lib/active_support/time_with_zone.rb')
-rw-r--r-- | activesupport/lib/active_support/time_with_zone.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 0d4c75d272..1949ce0ad3 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -130,7 +130,7 @@ module ActiveSupport # # With ActiveSupport.use_standard_json_time_format = false # Time.utc(2005,2,1,15,15,10).in_time_zone.to_json # # => "2005/02/01 15:15:10 +0000" - def to_json(options = nil) + def rails_to_json(options = nil) if !ActiveSupport.respond_to?(:use_standard_json_time_format) || ActiveSupport.use_standard_json_time_format xmlschema.inspect else @@ -138,6 +138,8 @@ module ActiveSupport end end + alias to_json rails_to_json + def to_yaml(options = {}) if options.kind_of?(YAML::Emitter) utc.to_yaml(options) |