From: Ed Sinjiashvili Date: 2002-04-27T14:34:58+09:00 Subject: Re: appending methods to class inside module Hello Ian, IM> The protected method was in class String and the method call was made IM> from an unrelated class, but it was made from an instance variable IM> that itself was of type String. You should judge your right on calling someone's methods depending on self at the point of *invocation*. Public methods: can be called no matter who self is Protected methods: can be called only if self has the same type as the target object (i.e. self if the object of the same (or descendent) class as the target) Private methods: can be called only on self So, in order to call your protected method of String, you should be a String or some kind of it. Since your Foo::Bar is obviously not a String you can't call String's protected methods. But you can become a kind of String: whailer% cat test.rb class String def check if self.length > 2048 puts "bad" else puts "good" end end protected :check end module Foo class Bar < ::String def initialize ; end def baz "hello".check end end end Foo::Bar.new.baz "don't do that".check whailer% whailer% ruby test.rb good test.rb:23: protected method `check' called for "don't do that":String (NameError) whailer% -- Ed