module == “singleton”(sometimes)<br />
module == “singleton”(sometimes)<br />
3<br />
1. static<br />
2. singleton<br />
3. class<br />
Singleton module<br />
Singleton module<br />
class Matt include Singletonend<br />
module<br />
✓<br /><ul><li>singleton
state</li></ul>✓<br />
module Matt extend selfend<br />
Extend self? WTF?<br />
extendv.include<br />
module Matt extend selfattr_accessor :handledef handle   @handle ||= “moonmaster9000” endend<br />
Upcoming SlideShare
Loading in …5
×

Module singleton

713 views
666 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
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
713
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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 />

×