aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/json.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/json.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/json.rb39
1 files changed, 2 insertions, 37 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/json.rb b/activesupport/lib/active_support/core_ext/object/json.rb
index 7c11d44f57..1675145ffe 100644
--- a/activesupport/lib/active_support/core_ext/object/json.rb
+++ b/activesupport/lib/active_support/core_ext/object/json.rb
@@ -62,40 +62,24 @@ class TrueClass
def as_json(options = nil) #:nodoc:
self
end
-
- def encode_json(encoder) #:nodoc:
- to_s
- end
end
class FalseClass
def as_json(options = nil) #:nodoc:
self
end
-
- def encode_json(encoder) #:nodoc:
- to_s
- end
end
class NilClass
def as_json(options = nil) #:nodoc:
self
end
-
- def encode_json(encoder) #:nodoc:
- 'null'
- end
end
class String
def as_json(options = nil) #:nodoc:
self
end
-
- def encode_json(encoder) #:nodoc:
- encoder.escape(self)
- end
end
class Symbol
@@ -108,10 +92,6 @@ class Numeric
def as_json(options = nil) #:nodoc:
self
end
-
- def encode_json(encoder) #:nodoc:
- to_s
- end
end
class Float
@@ -132,15 +112,8 @@ class BigDecimal
# if the other end knows by contract that the data is supposed to be a
# BigDecimal, it still has the chance to post-process the string and get the
# real value.
- #
- # Use <tt>ActiveSupport.encode_big_decimal_as_string = true</tt> to
- # override this behavior.
def as_json(options = nil) #:nodoc:
- if finite?
- ActiveSupport.encode_big_decimal_as_string ? to_s : self
- else
- nil
- end
+ finite? ? to_s : nil
end
end
@@ -166,10 +139,6 @@ class Array
def as_json(options = nil) #:nodoc:
map { |v| options ? v.as_json(options.dup) : v.as_json }
end
-
- def encode_json(encoder) #:nodoc:
- "[#{map { |v| v.as_json.encode_json(encoder) } * ','}]"
- end
end
class Hash
@@ -189,10 +158,6 @@ class Hash
Hash[subset.map { |k, v| [k.to_s, options ? v.as_json(options.dup) : v.as_json] }]
end
-
- def encode_json(encoder) #:nodoc:
- "{#{map { |k,v| "#{k.as_json.encode_json(encoder)}:#{v.as_json.encode_json(encoder)}" } * ','}}"
- end
end
class Time
@@ -225,7 +190,7 @@ class DateTime
end
end
-class Process::Status
+class Process::Status #:nodoc:
def as_json(options = nil)
{ :exitstatus => exitstatus, :pid => pid }
end