[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Protecting class "helper methods"?

Jay Levitt

8/23/2006 3:04:00 AM

Start with:

class C
def self.class_callme
internal_helper
end

def instance_callme
C.internal_helper
end

def self.internal_helper
puts "I'm not needed by the outside world."
end
end

My first instinct was to make internal_helper protected:

class << self
protected
def internal_helper
puts "I'm not needed by the outside world."
end
end

However, instance_methods (such as instance_callme) can't call protected
class methods.

Is there some other idiomatic Ruby way to, er, protect internal_helper, or
another way to call it from instance_callme? Or do I just have to do it
through lack of documentation with :nodoc:?

Jay Levitt