diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-07-21 16:38:02 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-07-21 16:38:02 -0500 |
commit | 12ae9d618e60b6e574c9816beb28278a80268da6 (patch) | |
tree | 9087d8f0ddb4c18569b7505aa1ac402b89eaa518 /activesupport | |
parent | 5b9d0a6272ca74f33cd62a4ff3fd3072fe533c09 (diff) | |
download | rails-12ae9d618e60b6e574c9816beb28278a80268da6.tar.gz rails-12ae9d618e60b6e574c9816beb28278a80268da6.tar.bz2 rails-12ae9d618e60b6e574c9816beb28278a80268da6.zip |
fixing :nodoc:s in AS::JSON::Encoding
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/json/encoding.rb | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/activesupport/lib/active_support/json/encoding.rb b/activesupport/lib/active_support/json/encoding.rb index c319e94bc6..389df58ec4 100644 --- a/activesupport/lib/active_support/json/encoding.rb +++ b/activesupport/lib/active_support/json/encoding.rb @@ -161,38 +161,67 @@ class Struct #:nodoc: end class TrueClass - def as_json(options = nil) self end #:nodoc: - def encode_json(encoder) to_s end #:nodoc: + def as_json(options = nil) #:nodoc: + self + end + + def encode_json(encoder) #:nodoc: + to_s + end end class FalseClass - def as_json(options = nil) self end #:nodoc: - def encode_json(encoder) to_s end #:nodoc: + def as_json(options = nil) #:nodoc: + self + end + + def encode_json(encoder) #:nodoc: + to_s + end end class NilClass - def as_json(options = nil) self end #:nodoc: - def encode_json(encoder) 'null' end #:nodoc: + def as_json(options = nil) #:nodoc: + self + end + + def encode_json(encoder) #:nodoc: + 'null' + end end class String - def as_json(options = nil) self end #:nodoc: - def encode_json(encoder) encoder.escape(self) end #:nodoc: + def as_json(options = nil) #:nodoc: + self + end + + def encode_json(encoder) #:nodoc: + encoder.escape(self) + end end class Symbol - def as_json(options = nil) to_s end #:nodoc: + def as_json(options = nil) #:nodoc: + to_s + end end class Numeric - def as_json(options = nil) self end #:nodoc: - def encode_json(encoder) to_s end #:nodoc: + def as_json(options = nil) #:nodoc: + self + end + + def encode_json(encoder) #:nodoc: + to_s + end end class Float # Encoding Infinity or NaN to JSON should return "null". The default returns # "Infinity" or "NaN" which breaks parsing the JSON. E.g. JSON.parse('[NaN]'). - def as_json(options = nil) finite? ? self : nil end #:nodoc: + def as_json(options = nil) #:nodoc: + finite? ? self : nil + end end class BigDecimal @@ -216,7 +245,9 @@ class BigDecimal end class Regexp - def as_json(options = nil) to_s end #:nodoc: + def as_json(options = nil) #:nodoc: + to_s + end end module Enumerable @@ -226,7 +257,9 @@ module Enumerable end class Range - def as_json(options = nil) to_s end #:nodoc: + def as_json(options = nil) #:nodoc: + to_s + end end class Array @@ -262,7 +295,7 @@ class Hash Hash[subset.map { |k, v| [k.to_s, encoder.as_json(v, options)] }] end - def encode_json(encoder) + def encode_json(encoder) #:nodoc: # values are encoded with use_options = false, because we don't want hash representations from ActiveModel to be # processed once again with as_json with options, as this could cause unexpected results (i.e. missing fields); |