module ActiveSupport::JSON::Encoding

def const_missing(name)

Deprecate CircularReferenceError
def const_missing(name)
  if name == :CircularReferenceError
    message = "The JSON encoder in Rails 4.1 no longer offers protection from circular references. " \
              "You are seeing this warning because you are rescuing from (or otherwise referencing) " \
              "ActiveSupport::Encoding::CircularReferenceError. In the future, this error will be " \
              "removed from Rails. You should remove these rescue blocks from your code and ensure " \
              "that your data structures are free of circular references so they can be properly " \
              "serialized into JSON.\n\n" \
              "For example, the following Hash contains a circular reference to itself:\n" \
              "   h = {}\n" \
              "   h['circular'] = h\n" \
              "In this case, calling h.to_json would not work properly."
    ActiveSupport::Deprecation.warn message
    SystemStackError
  else
    super
  end
end

def encode_big_decimal_as_string

def encode_big_decimal_as_string
  message = \
    "The JSON encoder in Rails 4.1 no longer supports encoding BigDecimals as JSON numbers. Instead, " \
    "the new encoder will always encode them as strings.\n\n" \
    "You are seeing this error because you are trying to check the value of the related configuration, " \
    "`active_support.encode_big_decimal_as_string`. If your application depends on this option, you should " \
    "add the 'activesupport-json_encoder' gem to your Gemfile. For now, this option will always be true. " \
    "In the future, it will be removed from Rails, so you should stop checking its value."
  ActiveSupport::Deprecation.warn message
  true
end

def encode_big_decimal_as_string=(as_string)

def encode_big_decimal_as_string=(as_string)
  message = \
    "The JSON encoder in Rails 4.1 no longer supports encoding BigDecimals as JSON numbers. Instead, " \
    "the new encoder will always encode them as strings.\n\n" \
    "You are seeing this error because you have 'active_support.encode_big_decimal_as_string' in " \
    "your configuration file. If you have been setting this to true, you can safely remove it from " \
    "your configuration. Otherwise, you should add the 'activesupport-json_encoder' gem to your " \
    "Gemfile in order to restore this functionality."
  raise NotImplementedError, message
end