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
84
Block_is_everywhere.pdf
Masafumi Okura
December 11, 2019
Tweet
Share
More Decks by Masafumi Okura
See All by Masafumi Okura
オブジェクトしこう
okuramasafumi
2
150
Debugging Alba
okuramasafumi
1
87
Learning Ruby
okuramasafumi
5
430
How to build a conference for both newbies and seasoned devs
okuramasafumi
1
1.2k
Why doesn't Ruby have Boolean class?
okuramasafumi
4
1.9k
Writing Minitest clone in 30 minutes
okuramasafumi
0
300
Developing a Vim plugin with Ruby
okuramasafumi
0
530
On proposals
okuramasafumi
0
250
5
okuramasafumi
0
190
Other Decks in Programming
See All in Programming
品質とスピードを両立: TypeScriptの柔軟な型システムをバックエンドで活用する
kosui
8
2.2k
雑に思考を整理する技術と効能
konifar
55
25k
Rubyでたのしむクリエイティブコーディング/Enjoy Creative coding with Ruby
chobishiba
1
160
Code Reviews
bkuhlmann
4
880
ONE WEDGE_company_guide
1wedge_one
0
380
App Router への移行は「改善」となり得るのか?/ Can migration to App Router be an improvement
takefumiyoshii
8
2.1k
Front-end application development, Symfony-style(s)
dunglas
2
1.9k
educure_カリキュラム生操作マニュアル.pdf
linew_official
0
470
元気予報
suu_mire0726
0
860
Tailwind CSSを本気でカスタマイズする方法
fsubal
2
260
#phpcon_odawara オープン・クローズドなテストフィクスチャを求めて / open closed test fixtures
77web
3
220
Blue/Greenデプロイの導入による 運用フローの改善
kudoas
1
350
Featured
See All Featured
Happy Clients
brianwarren
91
6.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
258
12k
YesSQL, Process and Tooling at Scale
rocio
163
13k
A Philosophy of Restraint
colly
196
16k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
19
1.9k
Principles of Awesome APIs and How to Build Them.
keavy
120
16k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
Building Your Own Lightsaber
phodgson
98
5.7k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
76
41k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.9k
Thoughts on Productivity
jonyablonski
57
3.8k
Agile that works and the tools we love
rasmusluckow
324
20k
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ͷϒϩοΫΫϩʔδϟ
पғͷڥʹΞΫηεͰ͖ΔͷͰɺ ৭ʑͱϋοΫ͢Δ͜ͱ͕Ͱ͖Δ
ྫɿΧϯλΦϒδΣΫτ