Sha256: 199f83df262bf96d2856cc94e2935c78b3974bc905ea11779b747350ecfddd63

Contents?: true

Size: 613 Bytes

Versions: 7

Compression:

Stored size: 613 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 Object
      # 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

# * George Moschovitis <gm@navel.gr>

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nitro-0.25.0 lib/nitro/helper/debug.rb
nitro-0.26.0 lib/nitro/helper/debug.rb
nitro-0.27.0 lib/nitro/helper/debug.rb
nitro-0.28.0 lib/nitro/helper/debug.rb
nitro-0.29.0 lib/nitro/helper/debug.rb
nitro-0.30.0 lib/nitro/helper/debug.rb
nitro-0.31.0 lib/nitro/helper/debug.rb