Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RailsはRubyだ

Avatar for yoppi yoppi
December 13, 2012

 RailsはRubyだ

Railsアプリを作るときにlibを意識しようという話を社内でしました。

Avatar for yoppi

yoppi

December 13, 2012
Tweet

More Decks by yoppi

Other Decks in Programming

Transcript

  1. Object Oriented Programming w ϞδϡʔϧੑΛҙࣝ͢Δ w ֦ுੑ w ࠶ར༻ੑ w

    ͢΂ͯ͸඼࣭޲্ͱӡ༻อकͷͨΊ 12೥5݄30೔ਫ༵೔
  2. Ruby application • bin/ • lib/ • spec/ • Rakefile

    • Gemfile • ... 12೥5݄30೔ਫ༵೔
  3. Rails Application • app/ • lib/ • config/ • db/

    • spec/ • Rakefile • Gemfile 12೥5݄30೔ਫ༵೔
  4. event_king • lib/event_king.rb • lib/event_king/ • battle.rb • gift.rb •

    point.rb • spec/lib/event_king/ 12೥5݄30೔ਫ༵೔
  5. ότϧ # lib/event_king/battle.rb module EventKing class Battle def initialize(deck, boss)

    ... end def battle! ... end end end 12೥5݄30೔ਫ༵೔
  6. ใु # lib/event_king/gift.rb module EventKing class Gift def initialize(status) ...

    end def distribute ... end end end 12೥5݄30೔ਫ༵೔
  7. 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 12೥5݄30೔ਫ༵೔