Venkat Akkineni <venkatram.akkineni / gmail.com> wrote:

> Hi
> 
>               How would one create a method that is accessible from
> outside but avoid the subclass from overriding and changing the
> definition?

Something like this?

class Superclass
  def do_not_override
  end
  def self.method_added(s)
    if s == :do_not_override
      puts "Warning: you should not override this method"
    else super
    end
  end
end

That doesn't really prevent the programmer from working his will, but
then in Ruby *nothing* can prevent the programmer from working his will
(even "private" can be worked around, for example), so the warning seems
a reasonable approach.

m.