Created
March 10, 2015 17:57
-
-
Save sideshowcoder/0f1e774ed2227f2e8b14 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
| Outside in configuration | |
| class ObjectBuilder | |
| def initialize() | |
| someMoreDefaults = {} | |
| end | |
| def setFoo foo | |
| foo = foo | |
| end | |
| def setBar bar | |
| bar = bar | |
| end | |
| def setSomeMoreDefaults | |
| someMoreDefaults = someMoreDefaults | |
| end | |
| def build | |
| Object.new(foo, bar, someMoreDefaults, ...) | |
| end | |
| end | |
| Alternative inside out configuration | |
| class Object | |
| def initialize(someAttribute, configureMe) | |
| self.someAttribute = someAttribute | |
| configureMe(self) | |
| end | |
| def doGreatWork | |
| "Yeah work" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment