Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Ruby object model: A matter of life and death

2.217 visualizaciones

Publicado el

Ruby object model internals for MRI. These slides have some animations, so if you want to see them all, you should download it. Created with libreoffice impress

  • Sé el primero en comentar

Ruby object model: A matter of life and death

  1. 1. Ruby object model
  2. 2. Javier Lafora Working at ASPgems @eLafoelafosobrerailes.blogspot.com
  3. 3. In ruby everything is an object
  4. 4. objectflagsklassinstance_variables
  5. 5. MyClassflagsklasssuperinstance_variablesconstantsmethods
  6. 6. RBasic RClass RObject MyClass flags klass object instance_variables superflagsklass constantsinstance_variables methods
  7. 7. BasicObject *super *klass Object Module *super *super *klass *klass Musician *super *klass name=() name() Class *super *klass bruce IronMaiden *klass *super@name=”bruce” *klass
  8. 8. Every instance of RClass will be an instance of Class even Class itself
  9. 9. Unshamesly taken from Burkey Libbeys presentation“Rubys Object Model: Metaprogramming and other Magic”
  10. 10. BasicObject *super *klass Object *super *klass Musician *super *klass name=() name() bruce IronMaiden *klass *super@name=”bruce” *klass
  11. 11. BasicObject *super *klass Object *super *klass to_s() Musician *super *klass bruce IronMaiden *klass *super@name=”bruce” *klass
  12. 12. Extending an object
  13. 13. SINGLETON CLASSES
  14. 14. bruce IronMaiden *klass *super #bruce *klass *klass *super flight_plane()
  15. 15. Class Methods
  16. 16. Musician Class *super *super *klass *klass #Musician *super *klass awesome_musicians()
  17. 17. FAIL
  18. 18. Object *super Module Class *klass *super *klass #Musician *superMusician *klass *super awesome_musicians() *klassIronMaiden Class *super *super *klass *klass
  19. 19. BasicObject #BasicObject *super *super *klass *klass Object #Object *super *super *klass *klass Class *super Musician #Musician *klass *super *super *klass *klassIronMaiden #IronMaiden *super *super *klass *klass
  20. 20. “The superclass of the eigenclass of an objectis the objects class. The superclass of theeigenclass of a class is the eigenclass of theclasss superclass.” Paolo Perrotta
  21. 21. Modules and mixins
  22. 22. IronMaiden *super *klass ICSinger *super *klass high_pitch_from_hell() #bruce *klassbruce *super *klass
  23. 23. Musician *super *klass ICHeavyMetal *super *klass IronMaiden devil_horns() *super *klass #bruce *klass *super ICSinger *superbruce *klass *klass high_pitch_from_hell()
  24. 24. ICHeavyMetal HeavyMetal *super *klass *klass *iv_tbl *iv_tbl *m_tbl *m_tbl iv_tbl m_tbl devil_horns()
  25. 25. Object #Object *super *super *klass *klass m_tbl m_tbl Musician #Musician *super *super *klass *klass m_tbl m_tblICHeavyMetal HeavyMetal #HeavyMetal *super *super *super *klass *klass *klass *m_tbl *m_tbl *m_tblIronMaiden #IronMaiden *super *super *klass *klass *m_tbl *m_tbl
  26. 26. Object #Object Musician #MusicianICHeavyMetal HeavyMetal ICHeavyMetal:: HeavyMetal::InstanceMethods InstanceMethods HeavyMetal:: ClassMethods ICHeavyMetal:: IronMaiden ClassMethods #IronMaiden
  27. 27. Metaprogramming with Ruby – Paolo Perrotta http://mwrc2008.confreaks.com/11farley.html http://www.rubyinside.com/a-look-into-rubys-object-model-3940.html http://rhg.rubyforge.org/http://www.madebydna.com/all/code/2011/06/24/eigenclasses-demystified.html http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html http://www.atalon.cz/rb-om/ruby-object-model/#sc-inheritance-sample
  28. 28. Thank you

×