Last active
August 31, 2016 17:18
-
-
Save jgaskins/ddda6391f2cc8c70abf3c5f2aadf7a25 to your computer and use it in GitHub Desktop.
Comparing types of dependency injection
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 Widget | |
attr_writer :dependency | |
def dependency | |
@dependency ||= Dependency.new | |
end | |
end | |
widget = Widget.new | |
widget.dependency = StubbedDependency.new |
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 Widget | |
def initialize(dependency: Dependency.new) | |
@dependency = dependency | |
end | |
end | |
widget = Widget.new(dependency: StubbedDependency.new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment