Sha256: 5395c8575f0004a7a7dbd0e9bf8aa96c62941f60367797aea0a05b3d601d7838

Contents?: true

Size: 584 Bytes

Versions: 2

Compression:

Stored size: 584 Bytes

Contents

module Nitro

# A collection of useful debuging methods.

module DebugHelper

private

  # Returns a <pre>-tag set with the +object+ dumped by YAML. 
  # Very readable way to inspect an object.
  #--
  # TODO: make safe html.
  #++
  
  def debug(object)
    begin
      Marshal::dump(object)
      "<pre class='debug_dump'>#{object.to_yaml.gsub("  ", "&nbsp; ")}</pre>"
    rescue TypeError => ex
      # Object couldn't be dumped, perhaps because of singleton 
      # methods, this is the fallback.
      "<code class='debug_dump'>#{object.inspect}</code>"
    end
  end

end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nitro-0.41.0 lib/nitro/helper/debug.rb
nitro-0.40.0 lib/nitro/helper/debug.rb