What is the use of 'abstract_method'?

What is the use of ‘abstract_method’ in rails?

–Rahul

On Jul 1, 6:01 am, Rahul P s [email protected] wrote:

What is the use of ‘abstract_method’ in rails?

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…)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs