Introspection, in Ruby

I was curious about what an object chart, or dependency graph, looks like in a running application. One of my favorite features about ruby is its ability to introspect; to have awareness of its own state at runtime.

Using the following snippet in your development Rails 4.x application, results in a verbose log file and a tremendously slow page-load time, but provides insightful information about the lifecycle of a request in Rails.

class Application < Rails::Application set_trace_func proc { |event, file, line, id, binding, classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } end

About Afomi

Afomi is the digital sandbox of Ryan Wold, who is always evolving this to better share inspirations and aspirations.

About Ryan

Ryan is a systems-thinking Product Developer and Designer who practices agile, test-driven, and lean continuous software delivery, while solving problems with people.

Random Posts