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
250
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
790
solving of multi-armed bandit problem in advertisement recommendation
yoppi
2
7.8k
recommendation system with document similarity
yoppi
0
3.2k
Other Decks in Programming
See All in Programming
rage against annotate_predecessor
junk0612
0
160
CloudflareのChat Agent Starter Kitで簡単!AIチャットボット構築
syumai
2
460
Improving my own Ruby thereafter
sisshiki1969
1
160
How Android Uses Data Structures Behind The Scenes
l2hyunwoo
0
310
MCPで実現するAIエージェント駆動のNext.jsアプリデバッグ手法
nyatinte
7
1.1k
Namespace and Its Future
tagomoris
6
700
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
430
250830 IaCの選定~AWS SAMのLambdaをECSに乗り換えたときの備忘録~
east_takumi
0
380
2025 年のコーディングエージェントの現在地とエンジニアの仕事の変化について
azukiazusa1
21
11k
AIでLINEスタンプを作ってみた
eycjur
1
230
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
270
開発チーム・開発組織の設計改善スキルの向上
masuda220
PRO
19
11k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
207
24k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
840
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.8k
Embracing the Ebb and Flow
colly
87
4.8k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Fireside Chat
paigeccino
39
3.6k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.6k
4 Signs Your Business is Dying
shpigford
184
22k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
18
1.1k
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ਫ༵