Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kaminariのコードリーディングをしよう
Search
manabeai
October 30, 2025
Programming
0
23
Kaminariのコードリーディングをしよう
manabeai
October 30, 2025
Tweet
Share
More Decks by manabeai
See All by manabeai
関数型プログラミングで 「脳がバグる」を乗り越える
manabeai
2
370
dry-monadsで安全に副作用を扱おう
manabeai
0
140
Other Decks in Programming
See All in Programming
余白を設計しフロントエンド開発を 加速させる
tsukuha
6
1.8k
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
500
Patterns of Patterns
denyspoltorak
0
1k
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
150
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
1
220
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
900
ThorVG Viewer In VS Code
nors
0
700
Grafana:建立系統全知視角的捷徑
blueswen
0
300
Architectural Extensions
denyspoltorak
0
190
高速開発のためのコード整理術
sutetotanuki
1
240
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
190
CSC307 Lecture 03
javiergs
PRO
1
480
Featured
See All Featured
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
54
Skip the Path - Find Your Career Trail
mkilby
0
44
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
100
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
How to make the Groovebox
asonas
2
1.9k
Designing for Timeless Needs
cassininazir
0
120
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
51
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
140
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.1k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
400
Making Projects Easy
brettharned
120
6.6k
Transcript
Kaminariのコードリーディング をしよう 発表者: manabeai
開発あるある • エラーがよくわからん! • ググりがち • AIに聞きがち • Ruby言語の特性上、 コードジャンプできないことも
ソースコードを読んでいますか?
コードリーディングの利点 • 意図を読み解く能力が上がる • その言語の文化、構文を知れる。 • 適切な抽象化の匙加減がつかめる。
ソースコードをちゃんと読もう 通勤中...
今回読むGem • ページネーションライブラリKaminari • ActiveRecordやActionViewの連携も可能
なぜkaminariなのか • Rubyらしい • Railsらしい
None
Kaminariのしくみ • クラスメソッド: pageはどこから? ◦ ちなみに pageはインスタンスメソッドとしても使える • インスタンスメソッド: perはどこから?
Kaminariのしくみ • インスタンスメソッド: current_pageはどこから?
コードジャンプができない! githubで検索
コードジャンプができない! Ruby 3.4 リファレンスマニュアル :https://docs.ruby-lang.org/ja/latest/method/Object/i/method.html Object#methodメソッドを使う
メソッド定義を探す https://github.com/kaminari/kaminari/blob/ca4a5dcfce40ede7990ebfe00a12f21e78e910d9/kaminari-activerecord/lib/kaminari/activerecord.rb ::ActiveRecord::BaseにKaminari::ActiveRecordExtensionを includesしている
https://github.com/kaminari/kaminari/blob/ca4a5dcfce40ede7990ebfe00a12f21e78e910d9/kaminari-activerecord/lib/kaminari/activerecord/active_record_extension.rb
メソッド定義を探す https://github.com/kaminari/kaminari/blob/ca4a5dcfce40ede7990ebfe00a12f21e78e910d9/kaminari-activerecord/lib/kaminari/activerecord/active_record_extension.rb
Ruby 3.4 リファレンスマニュアル :https://docs.ruby-lang.org/ja/latest/method/Class/i/inherited.html
メソッド定義を探す ここでinheritedが実行される! 継承
メソッド定義を探す https://github.com/kaminari/kaminari/blob/ca4a5dcfce40ede7990ebfe00a12f21e78e910d9/kaminari-activerecord/lib/kaminari/activerecord/active_record_extension.rb • ActiveRecord::Baseが継承されるタイミングで実行
None
メソッド定義を探す • Kaminari.config.page_method_nameは pageメソッド • 設定で任意のメソッドに変えられる • extendingについてはこちら https://railsdoc.com/page/extending
メソッド定義を探す • perメソッドはここに
まとめ • Rubyは言語の性質上コードジャンプができなくて定義を負いにくいこともある • まずはリファレンスをよく読み、それでも解決しなければソースコードをよく見てみよ う