Sha256: a04ff88a6be700169a2009f66e6517bd2d777b8c1fda92f48c9654177aedf06b

Contents?: true

Size: 809 Bytes

Versions: 10

Compression:

Stored size: 809 Bytes

Contents

module Debugging
  # Attempt to safely convert an object to a useful string (without side
  # effects if possible)
  #
  # Feel free to add support for more objects/responses/etc.
  def self.dump(obj)
    case obj
    when ::Symbol
      obj.inspect
    when ::String
      obj
    when ::Regexp
      obj.inspect
    when ::IO
      obj.inspect
    when ::Array
      obj.map { |a| Debugging.dump(a) }.to_s
    when ::Celluloid::Response::Success
      "SuccessResponse(#{dump(obj.value)}) (#{dump(obj.call)})"
    when ::Celluloid::Call
      args = obj.arguments.map { |a| Debugging.dump(a) }
      "Call: #{obj}-> #{obj.method.inspect}(#{args.join(', ')})"
    else
      begin
        obj.__send__(:__class__).to_s
      rescue NoMethodError
        obj.__send__(:class).to_s
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
celluloid-0.18.0 spec/support/debugging.rb
celluloid-0.17.4 spec/support/debugging.rb
celluloid-0.18.0.pre2 spec/support/debugging.rb
celluloid-0.18.0.pre spec/support/debugging.rb
celluloid-0.17.3 spec/support/debugging.rb
celluloid-0.17.2 spec/support/debugging.rb
celluloid-0.17.1.2 spec/support/debugging.rb
celluloid-0.17.1.1 spec/support/debugging.rb
celluloid-0.17.1 spec/support/debugging.rb
celluloid-0.17.0 spec/support/debugging.rb