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
Masafumi Okura
December 11, 2019
Programming
0
97
Block_is_everywhere.pdf
Masafumi Okura
December 11, 2019
Tweet
Share
More Decks by Masafumi Okura
See All by Masafumi Okura
Creating gems 101
okuramasafumi
1
58
How NOT to make your DSL terrible
okuramasafumi
0
250
オブジェクトしこう
okuramasafumi
2
200
Debugging Alba
okuramasafumi
1
170
Learning Ruby
okuramasafumi
5
530
How to build a conference for both newbies and seasoned devs
okuramasafumi
1
1.6k
Why doesn't Ruby have Boolean class?
okuramasafumi
4
2.1k
Writing Minitest clone in 30 minutes
okuramasafumi
0
470
Developing a Vim plugin with Ruby
okuramasafumi
0
650
Other Decks in Programming
See All in Programming
サーバーレスで負荷試験!Step Functions + Lambdaを使ったk6の分散実行
shuntakahashi
6
1.5k
令和トラベルにおけるLLM活用事例:社内ツール開発から得た学びと実践
ippo012
0
120
LangChainでWebサイトの内容取得やGitHubソースコード取得
shukob
0
150
Jakarta EE meets AI
ivargrimstad
0
360
Method Swizzlingを行うライブラリにおけるマルチモジュール設計
yoshikma
0
110
GenU導入でCDKに初挑戦し、悪戦苦闘した話
hideg
0
140
A New Era of Testing
mannodermaus
2
160
Swiftコードバトル必勝法
toshi0383
0
150
僕が思い描くTypeScriptの未来を勝手に先取りする
yukukotani
9
2.3k
Increased Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
180
Hono・Prisma・AWSでGeoなAPI開発
nokonoko1203
5
670
Scala アプリケーションのビルドを改善してデプロイ時間を 1/4 にした話 | How I improved the build of my Scala application and reduced deployment time by 4x
nomadblacky
1
160
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
157
15k
Writing Fast Ruby
sferik
623
60k
Designing with Data
zakiwarfel
98
5k
Designing Experiences People Love
moore
138
23k
What’s in a name? Adding method to the madness
productmarketing
PRO
21
3k
A Philosophy of Restraint
colly
202
16k
Thoughts on Productivity
jonyablonski
66
4.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
47
48k
Music & Morning Musume
bryan
46
6k
Producing Creativity
orderedlist
PRO
340
39k
Scaling GitHub
holman
458
140k
Become a Pro
speakerdeck
PRO
22
4.9k
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ͷϒϩοΫΫϩʔδϟ
पғͷڥʹΞΫηεͰ͖ΔͷͰɺ ৭ʑͱϋοΫ͢Δ͜ͱ͕Ͱ͖Δ
ྫɿΧϯλΦϒδΣΫτ