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
RailsはRubyだ
Search
yoppi
December 13, 2012
Programming
0
230
RailsはRubyだ
Railsアプリを作るときにlibを意識しようという話を社内でしました。
yoppi
December 13, 2012
Tweet
Share
More Decks by yoppi
See All by yoppi
Applying oCPC algorithm for production
yoppi
2
720
solving of multi-armed bandit problem in advertisement recommendation
yoppi
2
7.3k
recommendation system with document similarity
yoppi
0
3.1k
Other Decks in Programming
See All in Programming
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
450
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
3
280
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
バグを見つけた?それAppleに直してもらおう!
uetyo
0
180
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
6
1.1k
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
430
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
260
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
370
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
Итераторы в Go 1.23: зачем они нужны, как использовать, и насколько они быстрые?
lamodatech
0
790
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
330
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
790
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6.1k
The Invisible Side of Design
smashingmag
298
50k
Code Reviewing Like a Champion
maltzj
520
39k
Automating Front-end Workflow
addyosmani
1366
200k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Visualization
eitanlees
146
15k
Site-Speed That Sticks
csswizardry
2
190
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Code Review Best Practice
trishagee
65
17k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Transcript
RailsRubyͩ @yoppiblog Aktsuki.inc 125݄30ਫ༵
001 125݄30ਫ༵
Input Output ここ! 125݄30ਫ༵
Input Output 125݄30ਫ༵
Object Oriented Programming w ϞδϡʔϧੑΛҙࣝ͢Δ w ֦ுੑ w ࠶ར༻ੑ w
্࣭ͯ͢ͱӡ༻อकͷͨΊ 125݄30ਫ༵
)PX 125݄30ਫ༵
Testable Code • ςετΛॻ͘͜ͱͰڧ੍తʹϞδϡʔϧ Λҙࣝ͢Δ͜ͱʹͳΔ • ΠϯλϑΣʔεઃܭྗΛʹ͚ͭΔ 125݄30ਫ༵
RailsRuby 125݄30ਫ༵
Ruby application • bin/ • lib/ • spec/ • Rakefile
• Gemfile • ... 125݄30ਫ༵
Rails Application • app/ • lib/ • config/ • db/
• spec/ • Rakefile • Gemfile 125݄30ਫ༵
lib/ 125݄30ਫ༵
• RubyΞϓϦͷࠜװͱͳΔ෦ • RailsΞϓϦͰmonkey patchίʔυ gemͷ֦ுίʔυɺϩδοΫϞδϡʔϧ Λઃஔ͢Δ lib/ 125݄30ਫ༵
case study 125݄30ਫ༵
KingΠϕϯτ • Ϙεότϧ • ใु • ϙΠϯτ༩ 125݄30ਫ༵
event_king • lib/event_king.rb • lib/event_king/ • battle.rb • gift.rb •
point.rb • spec/lib/event_king/ 125݄30ਫ༵
# lib/event_king.rb module EventKing require 'event_king/battle' require 'event_king/gift' require 'event_king/point'
end module loader 125݄30ਫ༵
ότϧ # lib/event_king/battle.rb module EventKing class Battle def initialize(deck, boss)
... end def battle! ... end end end 125݄30ਫ༵
ใु # lib/event_king/gift.rb module EventKing class Gift def initialize(status) ...
end def distribute ... end end end 125݄30ਫ༵
ϙΠϯτ༩ # lib/event_king/point.rb module EventKing class Point def initialize(status) ...
end def distribute ... end end end 125݄30ਫ༵
Controller # app/controller/ user_event_king_boss_battle_logs.rb require ‘event_king’ class UserEventKingBossBattleLogsController def create
... battle = EventKing::Battle.new(deck, boss) battle.battle! log = Log.create(battle) ... end end 125݄30ਫ༵
·ͱΊ • RailsRubyΞϓϦέʔγϣϯͷͻͱͭ • testableͳίʔυΛॻ͘͜ͱͰશମͷ ࣭Λอͪͭͭӡ༻ָ͕ʹͳΔ • ϦϑΝΫλϦϯάΛڪΕͳ͍ • ςετॻ͖·͠ΐ͏
125݄30ਫ༵
ࢀߟจݙ • ΦϒδΣΫτࢦೖ ্/Լ • ॳΊͯͷRuby • Ruby ϕετϓϥΫςΟε •
ଟ͋ΔΦʔϓϯιʔεͷίʔυ 125݄30ਫ༵