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