Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/trunk/activesupport/lib/active_support/json/encoders/enumerable.rb

Revision 9093, 411 bytes (checked in by pratik, 5 months ago)

Improve documentation.

Line 
1 module Enumerable
2   # Returns a JSON string representing the enumerable. Any +options+
3   # given will be passed on to its elements. For example:
4   #
5   #   users = User.find(:all)
6   #   # => users.to_json(:only => :name)
7   #
8   # will pass the <tt>:only => :name</tt> option to each user.
9   def to_json(options = {}) #:nodoc:
10     "[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ', '}]"
11   end
12 end
Note: See TracBrowser for help on using the browser.