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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
manabeai
October 30, 2025
Programming
0
26
Kaminariのコードリーディングをしよう
manabeai
October 30, 2025
Tweet
Share
More Decks by manabeai
See All by manabeai
関数型プログラミングで 「脳がバグる」を乗り越える
manabeai
2
380
dry-monadsで安全に副作用を扱おう
manabeai
0
150
Other Decks in Programming
See All in Programming
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
740
Data-Centric Kaggle
isax1015
2
780
Architectural Extensions
denyspoltorak
0
300
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
290
Package Management Learnings from Homebrew
mikemcquaid
0
230
Amazon Bedrockを活用したRAGの品質管理パイプライン構築
tosuri13
5
770
Grafana:建立系統全知視角的捷徑
blueswen
0
330
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
7.5k
Apache Iceberg V3 and migration to V3
tomtanaka
0
170
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.5k
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
200
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
470
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
72
12k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
170
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
140
Tell your own story through comics
letsgokoyo
1
810
We Have a Design System, Now What?
morganepeng
54
8k
Producing Creativity
orderedlist
PRO
348
40k
Crafting Experiences
bethany
1
49
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Designing Powerful Visuals for Engaging Learning
tmiket
0
240
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
100
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は言語の性質上コードジャンプができなくて定義を負いにくいこともある • まずはリファレンスをよく読み、それでも解決しなければソースコードをよく見てみよ う