On Jun 2, 8:05 am, "Rick DeNatale" <rick.denat... / gmail.com> wrote: > On 6/2/07, Trans <transf... / gmail.com> wrote: > > > > > > > On Jun 1, 6:57 pm, "Rick DeNatale" <rick.denat... / gmail.com> wrote: > > > Now if one wanted to avoid re-defining such inner methods, one could > > > write something like: > > > > class A > > > def outer > > > unless self.class.instance_methods(false).include?(:inner) > > > def inner > > > "inner: a regular instance method" > > > end > > > end > > > unless singleton_methods(false).include?(:my_inner) > > > def self.my_inner > > > "my_inner: a singleton instance method" > > > end > > > end > > > end > > > end > > > Could. Though the would not work if the method were defined in an > > included module. > > It was a conscious choice on my part to using instance_methods(false) > for the instance method. This allows overriding with a new method, but > not redefining it the second time. If you wanted to not override then > you could use just instance_methods with the default true parameter > which returns methods from superclasses and included modules also. > > It's a matter of what you are trying to do. There are other techniques > for determining the current state, like using defined?, with different > variations and edge cases. Oh, I wasn't saying anything about your code. It's fine. I was just further pointing out the slightly odd behavior that one might not expect (I know I didn't), when using a module instead of a class. Here's an example: module N def a def b "foo" end end end class X include N end X.new.a N.instance_methods(false) #=> ["a", "b"] Notice #b isn't defined in X. T.