On Thu, Jul 30, 2009 at 9:00 PM, Matt Neuburg<matt_neuburg / tidbits.com> wro=
te:
> Venkat Akkineni <venkatram.akkineni / gmail.com> wrote:
>
>> Hi
>>
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 How would one create a method that is access=
ible from
>> outside but avoid the subclass from overriding and changing the
>> definition?
>
> Something like this?
>
> class Superclass
> =A0def do_not_override
> =A0end
> =A0def self.method_added(s)
> =A0 =A0if s =3D=3D :do_not_override
> =A0 =A0 =A0puts "Warning: you should not override this method"
> =A0 =A0else super
> =A0 =A0end
> =A0end
> end
>
> That doesn't really prevent the programmer from working his will, but
> then in Ruby *nothing*
with the exception of freeze, but that is not applicable here as
frozen classes can be subclassed without any problem and would be too
radical anyway.
But I thought if noteworthy that frozen objects and closures cannot be
"cracked" in Ruby.
Cheers
Robert