Last active
April 22, 2016 14:45
-
-
Save gotjosh/7282a7fc65c32e0c4c476cb1f5656be9 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
# Current | |
def initialize(resource = nil) | |
@resource = resource | |
end | |
private | |
def resource | |
@resource ||= ProductResource.new(connection: ExternalAdapter.instance.connection) | |
end | |
# Scenario 1 | |
def initialize(resource = ProductResource.new(connection: ExternalAdapter.instance.connection)) | |
@resource = resource | |
end | |
# Scenario 2 | |
def initialize(resource = ProductResource.build) | |
@resource = resource | |
end | |
class ProductResource | |
def self.build(adapter = ExternalAdapter.instance.connection) | |
new(connection: adapter) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment