Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,109 Points

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


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.