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
98
Graph Databases
fcofdez
1
240
Graph Databases
fcofdez
3
320
Other Decks in Programming
See All in Programming
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
520
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
高専キャリア LT 発表内容
crysta1221
6
5.6k
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
650
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
270
ALB ログから Trace を気合で繋げる技術
fohte
7
880
App Intentsのビルドプロセスを支える技術
kntkymt
0
190
【DroidKaigi 2026】「アクセシビリティを利用するとき、 アクセシビリティもまたこちらを利用している」 〜マルウェアによる攻撃と防衛について〜
halunoyo
0
440
自分的「カンファレンスの楽しみ方」
syumai
0
200
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
150
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
スマート反転とウェブアクセシビリティ
camiha
0
180
Featured
See All Featured
Facilitating Awesome Meetings
lara
57
7.1k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
How to Ace a Technical Interview
jacobian
281
24k
The World Runs on Bad Software
bkeepers
PRO
72
12k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
The agentic SEO stack - context over prompts
schlessera
0
920
Accessibility Awareness
sabderemane
1
210
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
A better future with KSS
kneath
240
18k
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