Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Modules Include and Extend Being Included

Can somebody explain me the purpose of self.include?

Okay, i have been following the Ruby courses and all is being explained really well. For some reason though my head won't wrap around this self.include. I have watched the vid mutliple times and google some cases but I just don't get it.

What's going on here? The Fetcher module is already included in the dog class so why would you want to included that one in the module with the self.include method?

Any help would be greatly appreciated.

2 Answers

Kevin Korte
Kevin Korte
28,148 Points

See if this helps you: http://www.jimmycuadra.com/posts/self-in-ruby/

http://stackoverflow.com/questions/6669527/use-of-ruby-self-keyword

This is a great question, and it's a difficult thing to get down. I learned a little bit myself researching your question. Let me know if that helps.

Charles Cloud
Charles Cloud
6,134 Points

My understanding is that it is basically this. The self.include method runs the code inside of that method whenever the module is included in a class.