What is the use of 'abstract_method' in rails?
--Rahul
What is the use of 'abstract_method' in rails?
--Rahul
http://www.noobkit.com/show/ruby/gems/io/rio/module/abstract_method.html defines it as: "abstract_method(symbol, …) extends Module defines a method which raises AbstractMethodCalled used in a base class to ensure that subclasses define an implementation"
It is used to cap the parent class of an inheritance.
so if class Foo < Bar
and Bar.some_method you want it to have to be defined in all subclasess (Foo and others...) you do like such:
class Bar def some_method abstract_method end end
then all subclasses must implement some_method or it will complain when being called (Note, untill it is called, everything is sweet, this can casue bugs...)