Sha256: 96ee70702caa96c226da938f523e62fc95ce4a98cc443ed4be857d10cfd90948

Contents?: true

Size: 596 Bytes

Versions: 1

Compression:

Stored size: 596 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

1 entries across 1 versions & 1 rubygems

Version Path
nitro-0.20.0 lib/nitro/mixin/debug.rb