instiki/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb
Jacques Distler 5292899c9a Rails 2.1 RC1
Updated Instiki to Rails 2.1 RC1 (aka 2.0.991).
2008-05-17 23:22:34 -05:00

13 lines
411 B
Ruby

module Enumerable
# Returns a JSON string representing the enumerable. Any +options+
# given will be passed on to its elements. For example:
#
# users = User.find(:all)
# # => users.to_json(:only => :name)
#
# will pass the <tt>:only => :name</tt> option to each user.
def to_json(options = {}) #:nodoc:
"[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ', '}]"
end
end