method
extend
![Moderate documentation Importance_2](https://d2vfyqvduarcvs.cloudfront.net/images/importance_2.png?1349367920)
extend(*args)
public
Register or
log in
to add new notes.
lazylester -
September 9, 2009
![Default_avatar_30](https://www.gravatar.com/avatar/2892f8fe56ed73a3c774a5d03b91dc45?default=http://apidock.com/images/default_avatar_30.png&size=30)
1 thank
extend adds class methods too
Because classes are objects. So for example:
module Ispeak def says "greetings aliens!" end end module Ieat def eats "spinach" end end module Inhabitant def says "I'm strong to the finish" end end class Human extend Ispeak # add class methods from Ispeak include Inhabitant # add instance methods from Inhabitant end Human.extend Ieat # add class methods from Ieat puts Human.says # -> greetings aliens! puts Human.eats # -> spinach popeye = Human.new puts popeye.says # -> I'm strong to the finish