Ruby/Class/freeze
Материал из Wiki.crossplatform.ru
Extends a frozen class
class MyClass def my_method puts "This is the only method allowed in MyClass." end MyClass.freeze end class MySubclass < MyClass def my_method "This is only one of the methods available in MySubclass." end def my_other_method "This is the other one." end end MySubclass.new.my_method
Freeze a class
class MyClass def my_method puts "This is the only method allowed in MyClass." end MyClass.freeze end class MyClass def my_method puts "I like this implementation of my_method better." end end