Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Metaprogramming Ruby
Search
Francisco Fernández Castaño
February 15, 2013
Programming
120
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Metaprogramming Ruby
A short introduction to dynamic aspects of Ruby and Ruby Object model.
Francisco Fernández Castaño
February 15, 2013
More Decks by Francisco Fernández Castaño
See All by Francisco Fernández Castaño
Graph Databases, a little connected tour (Codemotion Rome)
fcofdez
0
150
Bases de datos de grafos, un recorrido conectado
fcofdez
0
99
Graph Databases
fcofdez
1
240
Graph Databases
fcofdez
3
320
Other Decks in Programming
See All in Programming
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
180
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
420
JRuby: Past, Present, and Future
headius
0
220
Simple Storage Service(S3) is not simple
iwatsukayura
0
120
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
260
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
390
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1k
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
660
速習iPhone Duo対応
yuukiw00w
2
920
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
330
Verilogで学ぶCPU自作入門.pdf
uyuki234
7
3.9k
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
580
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
510
Odyssey Design
rkendrick25
PRO
2
850
Believing is Seeing
oripsolob
1
240
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Between Models and Reality
mayunak
4
480
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Practical Orchestrator
shlominoach
192
12k
Utilizing Notion as your number one productivity tool
mfonobong
4
610
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
520
Transcript
None
Ruby • Orientado a objetos • Lenguaje dinámico • Partes
funcionales (Bloques)
Ruby es simple en apariencia, pero complejo por dentro, como
el cuerpo humano. tratando de hacer que Ruby sea natural, no simple. Yukihiro Matsumoto 'matz'
¿Pero qué es eso del “metaprogramming”?
¿Pero qué es eso del metaprogramming? Metaprogramming is the writing
of computer programs that write or manipulate other programs (or themselves) as their data. Wikipedia
None
¿Pero qué es eso del metaprogramming? • Manejo de mensajes
cuyo destino no es conocido • Capacidad de creación y modificación de clases en runtime
None
Debemos conocer el modelo de objetos de Ruby
Debemos conocer el modelo de objetos de Ruby
en ruby todo es un objeto 2.0.0-rc2 :001 > 1.class
=> Fixnum
en ruby todo se ejecuta dentro de un objeto 2.0.0-rc2
:002 > self => main 2.0.0-rc2 :003 > class MyClass 2.0.0-rc2 :004?> self 2.0.0-rc2 :005?> end => MyClass 2.0.0-rc2 :006 > self => main 2.0.0-rc2 :007 > class MyClass 2.0.0-rc2 :008?> def test 2.0.0-rc2 :009?> self 2.0.0-rc2 :010?> end 2.0.0-rc2 :011?> def self.class_method 2.0.0-rc2 :012?> self 2.0.0-rc2 :013?> end 2.0.0-rc2 :014?> end => nil 2.0.0-rc2 :015 > MyClass.new.test => #<MyClass:0x00000002397860> 2.0.0-rc2 :016 > MyClass.class_method => MyClass
MonkeyPatches 2.0.0-rc2 :017 > class String 2.0.0-rc2 :018?> def replace
2.0.0-rc2 :019?> "dont replace" 2.0.0-rc2 :020?> end 2.0.0-rc2 :021?> end => nil 2.0.0-rc2 :022 > "stast".replace => "dont replace"
Modelo de objetos de Ruby • La keyword class solo
cambia de contexto • Las clases también son objetos de la clase Class
Modelo de objetos de Ruby class MyClass def my_method() @var
= 1 end end Obj1 = MyClass.new Obj1.my_method
Modelo de objetos de Ruby
Jerarquía de Clases class Book include Printable include Document Ancestors
# => [Book, Document, Printable, Object, Kernel, BasicObject] end
Method Lookup
None
None
Conclusiones
Cosas que me he dejado fuera
Preguntas
None