p = Proc.new{ puts \'ok\' }
Is is possible to see the ruby code in the proc?
inspect
returns the memory location:
Although an old question, still, I wanted to share my thoughts.
You can use Pry gem and end up with something like this:
[11] pry> p = Proc.new{ puts 'ok' }
=> #
[12] pry> show-source p
From: (pry)
Number of lines: 1
p = Proc.new{ puts 'ok' }
Also, if you would use it from Rails context, you can put:
::Kernel.binding.pry
in your controllers or models, and
- require 'pry'; binding.pry
in your views, where you want to start debugging.
And in the tests, I use a combination, first require 'pry'
at the top, and then ::Kernel.binding.pry
where needed.
References: