Sha256: be5554b301fbab12590cc7c48aef90589486998973eaea87bfbe5cd98c8bdd08

Contents?: true

Size: 612 Bytes

Versions: 5

Compression:

Stored size: 612 Bytes

Contents

module Nitro

# A collection of useful debuging methods.

module DebugMixin

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

5 entries across 5 versions & 1 rubygems

Version Path
nitro-0.21.0 lib/nitro/mixin/debug.rb
nitro-0.21.2 lib/nitro/mixin/debug.rb
nitro-0.22.0 lib/nitro/mixin/debug.rb
nitro-0.23.0 lib/nitro/mixin/debug.rb
nitro-0.24.0 lib/nitro/mixin/debug.rb