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
Block_is_everywhere.pdf
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Masafumi Okura
December 11, 2019
Programming
110
0
Share
Block_is_everywhere.pdf
Masafumi Okura
December 11, 2019
More Decks by Masafumi Okura
See All by Masafumi Okura
Metaprogramming isn't real, it can't hurt you
okuramasafumi
0
160
Developing static sites with Ruby
okuramasafumi
1
430
Why doesn't Ruby have Boolean class - final version
okuramasafumi
0
400
Reading Rails 1.0 Source Code
okuramasafumi
0
370
RDoc meets YARD
okuramasafumi
4
250
Why doesn't Ruby have Boolean class?
okuramasafumi
0
55
My KaigiEffect at RubyKaigi 2025, part 1
okuramasafumi
1
110
Writing documentation can be fun with plugin system
okuramasafumi
0
270
Alba: Why, How and What's So Interesting
okuramasafumi
0
520
Other Decks in Programming
See All in Programming
LLM Plugin for Node-REDの利用方法と開発について
404background
0
100
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
1.7k
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
210
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
6
1.1k
inferと仲良くなる10分間
ryokatsuse
1
250
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
120
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
140
ReactとSvelteのその先、Ripple-TS / Beyond React and Svelte: Ripple-TS
ssssota
3
820
Migrations : C'est une question d'hygiène !
vinceamstoutz
0
1.8k
[BalkanRuby 2026] Drop your app/services!
palkan
3
680
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
0
100
今さら聞けないCancellationToken
htkym
0
180
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Documentation Writing (for coders)
carmenintech
77
5.3k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
360
Technical Leadership for Architectural Decision Making
baasie
3
380
Utilizing Notion as your number one productivity tool
mfonobong
4
310
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.3k
Heart Work Chapter 1 - Part 1
lfama
PRO
7
36k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Color Theory Basics | Prateek | Gurzu
gurzu
0
310
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Transcript
Block is everywhere Event: LegalForce Ruby Meet Up #1 Date:
2019-12-11 Speaker: େխ࢙
pp self • ໊લɿେխ࢙ • ॴଐɿϑϦʔϥϯε • ΤσΟλɿVim • Α͍͘ΔίϛϡχςΟɿGrow.rbʢओ࠵ʣɺTama.rbͳͲ
RubyͷϒϩοΫૉΒ͍͠
RubyͷϒϩοΫͷΘΕํ
RubyͷϒϩοΫ͕ΘΕ͍ͯΔՕॴ • RailsͷϨΠΞτͷϨϯμϦϯάʢyieldʣ • ֤छgemͷઃఆʢconfigure doʣ • RakeFactoryBotʹද͞ΕΔDSL • Ϧιʔεͷཧ
• ϑοΫͷఆٛ • etc…
RailsͷϨΠΞτͷϨϯμϦϯά • ϨΠΞτϑΝΠϧͷதʹ͋Δ”yield”࣮ϒϩοΫΛධՁ͠ ͍ͯΔ • RailsͷϏϡʔʢςϯϓϨʔτʣ࠷ऴతʹRubyͱ࣮ͯ͠ߦ͞ ΕΔͷͰೖΕࢠΛ࣮ݱ͢ΔͷʹϒϩοΫΛωετ͍ͤͯ͞Δͱ ࢥΘΕΔ • Ұ൪ແҙࣝʹϒϩοΫΛ͍ͬͯΔՕॴͰʁ
֤छgemͷઃఆ • “configure do |config|”ͱ͔ͷΞϨવϒϩοΫΛ͍ͬͯΔ • ίϯϑΟάΦϒδΣΫτʹΞΫηε͢Δͷ͕ײతʹͰ͖Δ • ઃఆ͞ΕΔଆ”config =
Config.new; yield(config)”Έ͍ͨʹ ॻ͚Δ • ࣮ϒϩοΫΛ͏ඞཁͳ͍…ʁ
DSL • DSLΛ࣮͢ΔͷʹϒϩοΫʢͱ͍͏ΑΓProcΦϒδΣΫτ ͱ”instance_eval”ϝιουʣඞਢ • RSpecͩͱϒϩοΫΛ࣮ߦ͢Δͨͼʹಗ໊ΫϥεΛ࡞͍ͯͨ͠ Γ͢Δ • ʮϝλϓϩάϥϛϯάRubyʯͱ͍͏໊ஶΛಡΉͱΈ͕Θ͔Δ
Ϧιʔεͷཧ • “File.open do |f|”͕දత • “Net::HTTP.start do |http|”ͳΜ͔ͦ͏ •
ϝιου͕ϦιʔεΛ࡞͠ɺϒϩοΫ͕ด͡ΔͱϦιʔε ด͡ΒΕΔ
ϑοΫͷఆٛ • RSpecͷ”before(:each)”Railsͷ”before_action”ͳͲ͕දత • ϒϩοΫͷதΛProcΦϒδΣΫτͱͯ࣋ͪ͠ճ͢ • aroundܥͷϑοΫ෦ͰyieldΛݺͿͱຊॲཧ͕ΔͷͰೋ ॏʹϒϩοΫΛ͍ͬͯΔ
ଞʹ৭ʑͳϝιου͕ϒϩοΫΛड͚Δ • Enumerable#countʢϒϩοΫ͕trueͷཁૉΛ͑Δʣ • ActiveRecord::Relation#buildʢϒϩοΫͰΠϯελϯεઃఆʣ • Hash.newʢॳظԽͷํ๏Λنఆʣ • String#gsubʢஔͷํ๏Λنఆʣ
͓·͚
RubyͷϒϩοΫΫϩʔδϟ
पғͷڥʹΞΫηεͰ͖ΔͷͰɺ ৭ʑͱϋοΫ͢Δ͜ͱ͕Ͱ͖Δ
ྫɿΧϯλΦϒδΣΫτ