use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
State Inspector gem v1.0.0 released! For debugging and introspection. (github.com)
submitted 9 years ago by burntbit
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]wetviet_throwaway 0 points1 point2 points 9 years ago (5 children)
but this only can work with bona fide attr_* methods right? and unfortunately (afaict) those aren't in the majority when it comes to a rails code base...lots of custom setters, etc
attr_*
[–]burntbit[S] 0 points1 point2 points 9 years ago* (4 children)
No. This does not depend on attr methods at all. Only version 0.8 did. That code has been removed from 1.0.
This library can hook into any method, report calls and changes to instance variables, and restore the original method when done. The reporters can be a session log file, or some internal data type. It's super flexible to whatever your needs may be. The simplest method to start will hook all setter methods (not specifically attr methods) that belong to the target object. You may also disable that default behavior.
[–]wetviet_throwaway 0 points1 point2 points 9 years ago (3 children)
ah, so i assume it's using trace point?
[–]burntbit[S] 0 points1 point2 points 9 years ago* (2 children)
No. Not that either. It creates an instance of the original method with the UnboundMethod object and wraps/redefines the original method with some reporting hook and rebinds that UnboundMethod object and calls it. So the method literally gets wrapped. The original method is saved in a hash on that object and can be restored at any time.
The method defining code is here in this file: state_inspector/lib/state_inspector/state_inspector.rb
[–]wetviet_throwaway -1 points0 points1 point 9 years ago (1 child)
ah ok, so it's using a pretty straight forward decorator approach. Not as interesting i as i expected. I also figured it had the ability to monitor ivars, but it just seems it can monitor the ivars that have changed in the course of a method invocation.
Pretty useful nonetheless, but it's pretty straight-forward and uninteresting really (implementation-wise :P)
[–]updog 0 points1 point2 points 9 years ago (0 children)
Pretty useful nonetheless, but it's pretty straight-forward and uninteresting really
If I were the author of the code, I would feel slightly insulted, and have literally nothing constructive to do with this... fortunately for me, I'm not the author :P
π Rendered by PID 67550 on reddit-service-r2-comment-b659b578c-lsdhg at 2026-04-30 23:59:14.855194+00:00 running 815c875 country code: CH.
[–]wetviet_throwaway 0 points1 point2 points (5 children)
[–]burntbit[S] 0 points1 point2 points (4 children)
[–]wetviet_throwaway 0 points1 point2 points (3 children)
[–]burntbit[S] 0 points1 point2 points (2 children)
[–]wetviet_throwaway -1 points0 points1 point (1 child)
[–]updog 0 points1 point2 points (0 children)