instiki/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb
Jacques Distler 664552ac02 Rails 2.3.3.1
Update to latest Rails.
A little bit of jiggery-pokery is involved, since they
neglected to re-include vendored Rack in this release.
2009-08-04 10:16:03 -05:00

18 lines
412 B
Ruby

module Enumerable
# Coerces the enumerable to an array for JSON encoding.
def as_json(options = nil) #:nodoc:
to_a
end
end
class Array
# Returns a JSON string representing the Array. +options+ are passed to each element.
def to_json(options = nil) #:nodoc:
"[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ','}]"
end
def as_json(options = nil) #:nodoc:
self
end
end