File: active_support/json/encoders/enumerable.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

Class Hierarchy

Object ( Builtin-Module )
  Array    #8

Code

   1  module Enumerable
   2    # Coerces the enumerable to an array for JSON encoding.
   3    def as_json(options = nil) #:nodoc:
   4      to_a
   5    end
   6  end
   7 
   8  class Array
   9    # Returns a JSON string representing the Array. +options+ are passed to each element.
  10    def to_json(options = nil) #:nodoc:
  11      "[#{map { |value| ActiveSupport::JSON.encode(value, options) } * ','}]"
  12    end
  13 
  14    def as_json(options = nil) #:nodoc:
  15      self
  16    end
  17  end