Created
July 27, 2011 20:02
-
-
Save practicingruby/1110241 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Bot | |
| def initialize(parts) | |
| add_parts(parts) | |
| setup | |
| end | |
| def add_parts(parts) | |
| parts.each { |part| extend(part) } | |
| end | |
| # meant to be overrided by parts. | |
| def setup | |
| end | |
| end | |
| module PartOne | |
| def setup | |
| super | |
| # do something | |
| end | |
| end | |
| module PartTwo | |
| def setup | |
| super | |
| # do something | |
| end | |
| end | |
| bot = Bot.new(PartOne, PartTwo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment