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
39
0
Share
Kaminariのコードリーディングをしよう
manabeai
October 30, 2025
More Decks by manabeai
See All by manabeai
関数型プログラミングで 「脳がバグる」を乗り越える
manabeai
2
400
dry-monadsで安全に副作用を扱おう
manabeai
0
180
Other Decks in Programming
See All in Programming
Terraform言語の静的解析 / static analysis of Terraform language
wata727
1
140
AI-DLC Deep Dive
yuukiyo
9
5.6k
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
160
アクセシビリティ試験の"その後"を仕組み化する
yuuumiravy
1
200
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.7k
Kubernetesを使わない環境にもCloud Nativeなデプロイを実現する / Enabling Cloud Native deployments without the complexity of Kubernetes
linyows
3
350
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
140
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
430
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.7k
Road to RubyKaigi: Play Hard(ware)
makicamel
1
560
Kingdom of the Machine
yui_knk
2
1.5k
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
500
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
Building the Perfect Custom Keyboard
takai
2
750
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Rails Girls Zürich Keynote
gr2m
96
14k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
280
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
140
Design in an AI World
tapps
1
210
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は言語の性質上コードジャンプができなくて定義を負いにくいこともある • まずはリファレンスをよく読み、それでも解決しなければソースコードをよく見てみよ う