diff options
Diffstat (limited to 'activesupport/lib/active_support/json')
-rw-r--r-- | activesupport/lib/active_support/json/encoding.rb | 1 | ||||
-rw-r--r-- | activesupport/lib/active_support/json/variable.rb | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb index 389df58ec4..1a95bd63e6 100644 --- a/activesupport/lib/active_support/json/encoding.rb +++ b/activesupport/lib/active_support/json/encoding.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/object/to_json' require 'active_support/core_ext/module/delegation' +require 'active_support/json/variable' require 'bigdecimal' require 'active_support/core_ext/big_decimal/conversions' # for #to_s diff --git a/activesupport/lib/active_support/json/variable.rb b/activesupport/lib/active_support/json/variable.rb new file mode 100644 index 0000000000..8af661a795 --- /dev/null +++ b/activesupport/lib/active_support/json/variable.rb @@ -0,0 +1,17 @@ +require 'active_support/deprecation' + +module ActiveSupport + module JSON + # Deprecated: A string that returns itself as its JSON-encoded form. + class Variable < String + def initialize(*args) + ActiveSupport::Deprecation.warn 'ActiveSupport::JSON::Variable is deprecated and will be removed in Rails 4.1. ' \ + 'For your own custom JSON literals, define #as_json and #encode_json yourself.' + super + end + + def as_json(options = nil) self end #:nodoc: + def encode_json(encoder) self end #:nodoc: + end + end +end |