# File lib/puppet/external/pson/common.rb, line 302
302:   def dump(obj, anIO = nil, limit = nil)
303:     if anIO and limit.nil?
304:       anIO = anIO.to_io if anIO.respond_to?(:to_io)
305:       unless anIO.respond_to?(:write)
306:         limit = anIO
307:         anIO = nil
308:       end
309:     end
310:     limit ||= 0
311:     result = generate(obj, :allow_nan => true, :max_nesting => limit)
312:     if anIO
313:       anIO.write result
314:       anIO
315:     else
316:       result
317:     end
318:   rescue PSON::NestingError
319:     raise ArgumentError, "exceed depth limit"
320:   end