Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Module singleton

827 views

Published on

How a ruby module is actually a singleton... and how you can use this for great good.

Note: these slides make almost no sense without narration. That's intentional.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Module singleton

  1. 1. module == “singleton”(sometimes)<br />
  2. 2. module == “singleton”(sometimes)<br />
  3. 3. 3<br />
  4. 4. 1. static<br />
  5. 5. 2. singleton<br />
  6. 6. 3. class<br />
  7. 7. Singleton module<br />
  8. 8. Singleton module<br />
  9. 9. class Matt include Singletonend<br />
  10. 10. module<br />
  11. 11. ✓<br /><ul><li>singleton
  12. 12. state</li></ul>✓<br />
  13. 13. module Matt extend selfend<br />
  14. 14. Extend self? WTF?<br />
  15. 15. extendv.include<br />
  16. 16. module Matt extend selfattr_accessor :handledef handle @handle ||= “moonmaster9000” endend<br />
  17. 17. Matt = Module.new doattr_accessor :handledef handle @handle ||= “moonmaster9000” endendMatt.extend Matt<br />

×