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
340
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
260
LTの敷居を下げる / Lower the threshold for LT
sinsoku
1
270
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
1k
Railsアプリと型検査 / Rails app and type checking
sinsoku
5
1.1k
💎のつくりかた 2023 / How to make gems 2023
sinsoku
2
270
Make tests run faster
sinsoku
2
550
Get started with OSS contributions
sinsoku
2
1k
Advice for Ruby beginners
sinsoku
2
420
Railsエンジニア向けDocker入門 / Docker description for Rails engineers
sinsoku
0
630
Other Decks in Technology
See All in Technology
本当のAWS基礎
toru_kubota
1
550
LangSmith入門―トレース/評価/プロンプト管理などを担うLLMアプリ開発プラットフォーム
os1ma
5
530
いつか使うかも貯金してたらめちゃめちゃ機能が増えてた話
riyaamemiya
0
450
web-application-security
matsuihidetoshi
0
180
Cracking the KubeCon CfP
inductor
2
260
R3のコードから見る実践LINQ実装最適化・コンカレントプログラミング実例
neuecc
3
1.1k
ゼロから始めるVue.jsコミュニティ貢献 / first-vuejs-community-contribution-link-and-motivation
lmi
1
130
EMとして2023年度に頑張ったこと / What we did well in FY2023 as a EM
pauli
1
180
IaCジェネレーターとBedrockで詳細設計書を生成してみた
tsukasa_ishimaru
3
690
DMM.com アルファ室採用案内資料
hsugita
1
170
今日からできる!簡単 .NET 高速化 Tips -2024 edition-
xin9le
6
2.6k
生産性向上チームの紹介
cybozuinsideout
PRO
1
890
Featured
See All Featured
Designing with Data
zakiwarfel
96
4.8k
Unsuck your backbone
ammeep
663
57k
The Language of Interfaces
destraynor
151
23k
From Idea to $5000 a Month in 5 Months
shpigford
377
45k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
Rebuilding a faster, lazier Slack
samanthasiow
73
8.2k
In The Pink: A Labor of Love
frogandcode
138
21k
Product Roadmaps are Hard
iamctodd
44
9.7k
How GitHub (no longer) Works
holman
304
140k
Making Projects Easy
brettharned
108
5.5k
Six Lessons from altMBA
skipperchong
21
3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
659
120k
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