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
YARD with RBS Syntax
Search
Takumi Shotoku
July 06, 2023
Technology
1
410
YARD with RBS Syntax
【オフライン開催】Omotesando.rb #87
https://omotesandorb.connpass.com/event/287544/
Takumi Shotoku
July 06, 2023
Tweet
Share
More Decks by Takumi Shotoku
See All by Takumi Shotoku
Let's get started with Ruby && Rails Tips
sinsoku
0
310
LTの敷居を下げる / Lower the threshold for LT
sinsoku
1
280
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
1.1k
Railsアプリと型検査 / Rails app and type checking
sinsoku
5
1.2k
💎のつくりかた 2023 / How to make gems 2023
sinsoku
2
290
Make tests run faster
sinsoku
2
590
Get started with OSS contributions
sinsoku
2
1.1k
Advice for Ruby beginners
sinsoku
2
450
Railsエンジニア向けDocker入門 / Docker description for Rails engineers
sinsoku
0
660
Other Decks in Technology
See All in Technology
Git 研修 Basic【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
310
Scaling Technical Excellence at 104: Evolution in AWS and Developer Empowerment
scotthsieh825
1
150
[I/O Extended Android 2024] What`s new in Android 2024
kyeongwan
0
220
楽しくGoを学び合う、LayerXの勉強会文化 / LayerX's study culture of having fun and learning Go together
ar_tama
2
350
サーバーレスAPI(API Gateway+Lambda)とNext.jsで 個人ブログを作ろう!
shuntaka
PRO
0
560
フルリモートワークはエンジニアの夢を叶えたか? #cm_odyssey
mamohacy
2
600
Luupの開発組織におけるインシデントマネジメントの変遷 ver.RoadtoSRENEXT2024
grimoh
1
270
「単なる OAuth 2.0 を認証に使うと、車が通れるほどのどでかいセキュリティー・ホールができる」のか検証してみた
terara
0
380
LINE WORKSへ簡単通知!Incoming Webhookアプリの紹介
mmclsntr
0
110
エンジニアの生存戦略 〜クラウド潮流の経験から紐解く技術トレンドのメカニズムと乗りこなし方〜
shimy
9
1.9k
年間一億円削減した時系列データベースのアーキテクチャ改善~不確実性の高いプロジェクトへの挑戦~
lycorptech_jp
PRO
3
2.9k
ギークの理想が7つ集まるエムスリーで夢を叶えよう - エムスリー株式会社
m3_engineering
1
260
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
149
45k
BBQ
matthewcrist
82
9k
Optimising Largest Contentful Paint
csswizardry
18
2.6k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
34
1.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
44
4.7k
The World Runs on Bad Software
bkeepers
PRO
63
11k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
Pencils Down: Stop Designing & Start Developing
hursman
118
11k
Adopting Sorbet at Scale
ufuk
71
8.8k
Embracing the Ebb and Flow
colly
81
4.3k
Fireside Chat
paigeccino
25
2.8k
How to Think Like a Performance Engineer
csswizardry
4
590
Transcript
YARD with RBS Syntax Omotesando.rb #87 2023/07/06 1
ࣗݾհ • ໊લ: ਖ਼ಙ (aka: ਆ) • ձࣾ: - •
GitHub: @sinsoku (ը૾ӈ্) • Twitter: @sinsoku_listy (ը૾ӈԼ) • ͖ͳݴޠ: Rust • Railsྺ: 8͘Β͍ 2
ઌ݄͔ΒRBSΛ͍࢝Ί·ͨ͠ 3
͖͔͚ͬ: MedPeerͷϒϩά 4
ࣾͷ૯ҙ: ܕͷԸܙΛड͚͍ͨ ʢͨͩ͠ܕࣗͰॻ͖ͨ͘ͳ͍ʣ 5
RBSಋೖͷํ • *.rbs ࣗಈੜ͢Δ • rbs collection • rbs prototype
• sord1 ʢYARD -> rbsʣ • gemͷෆͯ͠Δܕఆٛ࠷খݶ͚ͩ༻ҙ 1 https://github.com/AaronC81/sord 6
ಋೖͷৄࡉׂѪʢͨͿΜϒϩάॻ͘ʣ 7
͔͜͜Βຊ 8
Α͋͘ΔYARDͷྫ class User # @param item [Item] ΞΠςϜ # @param
amount [Integer] ྔ # @param coupon [Coupon] Ϋʔϙϯ # @return [Boolean] ߪೖͷޭ/ࣦഊ def buy(item, amount, coupon = nil); end end 9
୭େͨ͠આ໌Λॻ͍͍ͯͳ͍ 10
ීஈܕ͚ͩॻ͚ेͰʁ 2 2 େࣄͳ෦ʹઆ໌Λॻ͚͘ͲɺܕͱҾ໊Ͱेͳέʔεଟ͍ɻ 11
ͦΜͳgemΛ࡞Γ·ͨ͠ 12
! yard-sig https://github.com/sinsoku/yard-sig 13
͜Ε͕ class User # @param item [Item] ΞΠςϜ # @param
amount [Integer] ྔ # @param coupon [Coupon] Ϋʔϙϯ # @return [Boolean] ߪೖͷޭ/ࣦഊ def buy(item, amount, coupon = nil); end end 14
͜͏ͳΔ class User # @!sig (Item, Integer, ?Coupon) -> bool
def buy(item, amount, coupon = nil); end end 15
yard-sig • YARDϓϥάΠϯ • yard doc --plugin sig Ͱ༻Մ3 •
จ๏RBS Syntaxͱಉ͡ • ෦Ͱ @param @return ͳͲͷλάʹม 3 .yardopts ʹ --plugin sig Λࢦఆ͢Δͱָ 16
σϞʢϦϦʔε࡞ۀʣ 17
͓·͚: Rails v7.0.5ͷ has_one ͕ਏ͍ 18
ͷཁ طଘϨίʔυ͕͋Δͱ͖ͷ create_association ͷڍಈ͕มΘΔɻ • v7.0.4: save(validate, INSERT) -> destroy(DELETE)
• v7.0.5: destroy(DELETE) -> save(validate, INSERT) v7.0.4·ͰผʑͷτϥϯβΫγϣϯͰɺόϦσʔγϣϯʹࣦഊ͠ ͯطଘϨίʔυ͕আ͞Ε͍ͯͨɻ 19
Өڹ͕͋Δέʔε 1. Uniquness Validator4 2. UNIQ constraint 3. DBґଘͷCustom Validation
• ྫ: ϨίʔυΛ࡞͔ͯ͠Β10Ҏ 4 v7.0.4ͰόάͬͯΔͷͰɺجຊతʹؾʹ͢Δඞཁ͕ͳ͍ͣɻ 20
rails/rails#48643 21