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
Rubyのメソッド解決チェーン
Search
すぎうり
June 23, 2026
Programming
26
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rubyのメソッド解決チェーン
すぎうり
June 23, 2026
More Decks by すぎうり
See All by すぎうり
BareRuby ~組み込み向けRubyAOTコンパイラ~
uproad3
0
25
AIコードアポカリプス
uproad3
0
49
負債解消という仕事は儲かる
uproad3
6
4.3k
RaspberryPi Picoの表現力の拡張 ~アナログコンピュータとの出会い~
uproad3
0
39
お前はまだRubyの 型の強さを知らない
uproad3
0
33
動的型解析器 Ethotrace
uproad3
0
20
お前はまだRubyの 型システムを知らない
uproad3
1
69
UdonRubyの実現可能性について
uproad3
0
37
RubyKaja 2026
uproad3
0
33
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
430
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
4
700
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
110
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
140
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.1k
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
340
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
560
SREの越境 / SRE Collaboration
y0hgi
2
230
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
3
550
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
250
PL/pgSQLはなぜ「ふつうのSQL」より遅いのか
tameguro
0
110
新卒PdEのリアル
ryu1013
1
500
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
590
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Facilitating Awesome Meetings
lara
57
7.1k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
580
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
570
My Coaching Mixtape
mlcsv
0
320
RailsConf 2023
tenderlove
30
1.5k
So, you think you're a good person
axbom
PRO
2
2.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
320
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.9k
Transcript
Rubyのメソッド解決チェーン すぎうり
メソッド解決チェーンとは Rubyがメソッドを呼ぶとき、どこを探しに行くか MyClass 呼ばれたクラス SuperClass 継承元クラス Object BasicObject ← 先に探す
後で探す → obj.greet # MyClass に greet があれば → 使う # なければ → SuperClass を探す → Object → BasicObject この探索順序がメソッド解決チェーン( Method Resolution Order)
include するとチェーンの後ろに入る module Greetable def greet; 'Hello!'; end end class
MyClass include Greetable end 解決チェーン MyClass Greetable Object MyClass の後ろ(継承元の手前)に差し込まれる MyClass.ancestors # => [MyClass, Greetable, Object, ...] MyClass.new.greet # => 'Hello!' クラス自身にメソッドがなければ、 includeしたモジュールに委ねる
prepend するとチェーンの先頭に入る module Greetable def greet puts 'called!' super end
end class MyClass prepend Greetable end MyClass.ancestors # => [Logger, MyClass, Object, ...] MyClass.new.greet # => 'called!' include の場合(参考) MyClass Greetable Object prepend の場合 Greetable MyClass Object MyClass より前(先頭)に割り込む どのメソッドを呼んでも、必ず prependのGreetableを通る
元のメソッドを変えずに、呼び出しを横取りできる 呼び出しの流れ 呼び出し元 prepend モジュール ← 先に通る 元のメソッド super で呼ばれる
戻り値 引数を記録する module Tracer def greet(name) # 引数を記録する $log << { method: :greet, args: [name], class: name.class } super # 元のメソッドを呼ぶ end end MyClass.prepend(Tracer)