From: Johannes Friestad Date: 2005-12-19T09:03:58+09:00 Subject: Re: How to know if a method is read-write or read-only I assume you mean methods that are property getters/setters, along the lines of 'user.name()'/'user.name=(name)', and that read-write or read-only refer to object properties like 'name'? There is no general way to determine whether a method updates object state or not. (Unless you start parsing bytecodes or hook into the VM parse tree, which is a somewhat larger project.) You'll have to rely on naming conventions, like "a method that takes no arguments and has a name not ending with '=' is a getter, a method that takes one argument and has a name ending with '=' is a setter". You can get the number of arguments from Method#arity, like Array.instance_method(:length).arity => 0 jf On 12/18/05, Trans wrote: > I've now come across a second usecase for knowing if a method is > read-write or read-only on it's object's state. Both cases boil-down to > having meta-method behave differently depending on the behavior of > method being delegated to, but the circumstances differ completely. To > give an example, the current case generates method wraps for any given > class, applying thread sycronization. If a method is read-only it's > wraped in a Sync::SH, if read-write then Sync::Ex. > > So I wonder, is there a way to determine this fact about a method? > > Thanks, > T.