aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/lib/active_support/json/encoders/enumerable.rb
blob: 881b1d62c1c451a14a77b1b980c597e4eff44f62 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                 


                                                                    

                                        

                                                              

                                                                            

     
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