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
550
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
Automatically generating types by running tests
sinsoku
2
8.1k
滅・サービスクラス🔥 / Destruction Service Class
sinsoku
8
2.3k
テストを書かないためのテスト/ Tests for not writing tests
sinsoku
1
240
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
280
"型"のあるRailsアプリケーション開発 / Typed Rails application development
sinsoku
10
2.7k
Let's get started with Ruby && Rails Tips
sinsoku
0
420
LTの敷居を下げる / Lower the threshold for LT
sinsoku
1
370
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
1.4k
Railsアプリと型検査 / Rails app and type checking
sinsoku
5
1.5k
Other Decks in Technology
See All in Technology
OTel meets Wasm: プラグイン機構としてのWebAssemblyから見る次世代のObservability
lycorptech_jp
PRO
0
200
Redmineの意外と知らない便利機能 (Redmine 6.0対応版)
vividtone
0
650
ソフトウェアは捨てやすく作ろう/Let's make software easy to discard
sanogemaru
2
180
AWS パートナー企業のテクニカルサポートが日々思っていること 〜そして、4/15 の現場から〜
kazzpapa3
2
380
オープンソースとビジネス: 位置情報の世界からみえる流れ / 札幌IT石狩鍋#2
sorami
0
220
MCP で繋ぐ Figma とデザインシステム〜LLM を使った UI 実装のリアル〜
kimuson
1
930
CloudTrailも、GuardDutyも、VPC Flow logsも… ログ多すぎ問題の整理術
nikuyoshi
4
540
VueUseから学ぶ実践TypeScript #TSKaigi #TSKaigi2025
bengo4com
3
5.3k
SmartHRの複数のチームにおけるMCPサーバーの活用事例と課題
yukisnow1823
1
800
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
3
1.5k
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.2k
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
12k
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
180
53k
Stop Working from a Prison Cell
hatefulcrawdad
269
20k
A designer walks into a library…
pauljervisheath
205
24k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
42
2.3k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
600
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Building Applications with DynamoDB
mza
95
6.4k
The Power of CSS Pseudo Elements
geoffreycrofte
76
5.8k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
KATA
mclloyd
29
14k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
14
1.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.5k
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