Last active
August 29, 2015 14:15
-
-
Save LNA/3fba7a61396c81e5b451 to your computer and use it in GitHub Desktop.
Dependency Injection
This file contains 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 BookShelf | |
def initialize(books, magazines, flowers) | |
@books = books | |
@magazines = magazines | |
@flowers = flowers | |
end | |
def find(book) | |
@books.find(book) | |
end | |
def arrange | |
@flowers.arrange | |
end | |
end |
This file contains 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 Books | |
#code | |
end | |
class Magazines | |
#code | |
end | |
class Flowers | |
#code | |
end |
This file contains 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
my_books = Books.new | |
my_magazines = Magazines.new | |
my_flowers = Flowers.new | |
my_bookshelf = BookShelf.new(my_books, my_magazines, my_flowers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment