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
いつか使える ObjectSpace / Maybe useful ObjectSpace
Search
Shintani Teppei
September 05, 2024
Programming
310
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
いつか使える ObjectSpace / Maybe useful ObjectSpace
Omotesando.rb#101 の発表資料です。
https://omotesandorb.connpass.com/event/328438/
Shintani Teppei
September 05, 2024
More Decks by Shintani Teppei
See All by Shintani Teppei
モノリス Rails でも日中に rails db:migrate を走らせたい! / Daytime rails db:migrate on Monolithic Rails!
euglena1215
4
730
すべてがオンボーディングタスクになる / Everything becomes an onboarding task
euglena1215
0
200
「地続き」の技術面接 / "Continuous" technical interview
euglena1215
0
140
allow_retry と Arel.sql / allow_retry and Arel.sql
euglena1215
2
340
AIと”コードの評価関数”を共有する / Share the "code evaluation function" with AI
euglena1215
1
320
ISUCONで型をつける
euglena1215
1
170
3年でバックエンドエンジニアが5倍に増えても破綻しなかったアーキテクチャ そして、これから / Software architecture that scales even with a 5x increase in backend engineers in 3 years
euglena1215
11
5.9k
モジュラモノリス、その前に / Modular monolith, before that
euglena1215
8
1.2k
rbs-inlineを導入してYARDからRBSに移行する
euglena1215
1
1k
Other Decks in Programming
See All in Programming
ChromeでローカルLLM
ryu1013
0
140
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
190
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.2k
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
210
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
370
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
370
すこし踏み込む CancellationToken
htkym
2
1.7k
R8 の設定見直しでアプリサイズ削減
andpad
0
220
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
170
Featured
See All Featured
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.2k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
270
A designer walks into a library…
pauljervisheath
211
25k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Are puppies a ranking factor?
jonoalderson
2
4.1k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
480
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
The SEO Collaboration Effect
kristinabergwall1
1
590
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Skip the Path - Find Your Career Trail
mkilby
1
260
Making Projects Easy
brettharned
120
6.8k
Transcript
2024/09/05 omotesando.rb #101 株式会社タイミー 新谷哲平 いつか使えるObjectSpace @euglena1215
自己紹介 Shintani Teppei(@euglena1215) • 株式会社タイミー • バックエンド テックリード • 最近は
Ruby よりも日本語を 書いています
最初に質問 ObjectSpace 知ってる方
こんな方向け • ObjectSpace 知らない・触ったことない → これまでできなかったことができるようになるかも?
ObjectSpaceってなに? ObjectSpace は Ruby の組み込みライブラリ https://docs.ruby-lang.org/ja/latest/class/ObjectSpace.html
ObjectSpaceってなに? ObjectSpace は Ruby の組み込みライブラリ https://docs.ruby-lang.org/ja/latest/class/ObjectSpace.html
ObjectSpaceってなに? ObjectSpace は Ruby の組み込みライブラリ https://docs.ruby-lang.org/ja/latest/class/ObjectSpace.html 🧙🔮🧙
ObjectSpaceってなに? 今回は ObjectSpace モジュールに定義されているメソッド3つを紹介 • ObjectSpace._id2ref • ObjectSpace.count_objects • ObjectSpace.each_object
ObjectSpace._id2ref
ObjectSpace._id2ref オブジェクトIDからオブジェクトを取得する
ObjectSpace._id2ref Q. どんなときに使える?
ObjectSpace._id2ref Q. どんなときに使える? A. Rails 6より前の ActiveSupport Instrumentation API の
sql.active_record では connection_id を受け取っていた。id から connection を取得するために必要。
ObjectSpace._id2ref Q. どんなときに使える? A. Rails 6より前の ActiveSupport Instrumentation API の
sql.active_record では connection_id を受け取っていた。id から connection を取得するために必要。 おそらく現代において使うことはほとんどないのでは...?
ObjectSpace.count_objects
ObjectSpace.count_objects オブジェクトの種類ごとに現時点で生成されている個数を返す
ObjectSpace.count_objects 例:blockとして渡した処理で生成されたHashオブジェクトの個数を返すメソッド
ObjectSpace.count_objects 例:blockとして渡した処理で生成されたHashオブジェクトの個数を返すメソッド
ObjectSpace.count_objects Q. どんなときに使える?
ObjectSpace.count_objects Q. どんなときに使える? A. メモリを意識したコードを書きたくなったとき...?
ObjectSpace.count_objects Q. どんなときに使える? A. メモリを意識したコードを書きたくなったとき...? Model.where(...).map(&:user_id) と Model.where(...).pluck(:user_id) の 生成オブジェクト数の違いを見てみると面白いかも
ObjectSpace.each_object
ObjectSpace.each_object 全てのオブジェクトもしくは任意のクラスのオブジェクトに繰り返し処理を行う
メタプログラミング Ruby の時間です クラスは全て Class クラスのインスタンス(オブジェクト)
メタプログラミング Ruby の時間です クラスは全て Class クラスのインスタンス(オブジェクト) ObjectSpace.each_object(Class) を実行すると...
メタプログラミング Ruby の時間です クラスは全て Class クラスのインスタンス(オブジェクト) ObjectSpace.each_object(Class) を実行すると... 定義されている全クラスの一覧を取得できる 🔮
ObjectSpace.each_object 全クラスの一覧が取得できるなら、特定クラスを継承したクラス一覧も取得できる ApplicationRecord を継承したクラスの一覧、ApplicationJob を継承したクラスの 一覧とか出せると便利なことがたまにある
ObjectSpace知ってると便利なことが稀にある 良い Ruby プログラミングライフを!