Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Created March 10, 2015 17:57
Show Gist options
  • Select an option

  • Save sideshowcoder/0f1e774ed2227f2e8b14 to your computer and use it in GitHub Desktop.

Select an option

Save sideshowcoder/0f1e774ed2227f2e8b14 to your computer and use it in GitHub Desktop.
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