Created
March 31, 2016 13:28
-
-
Save spanuska/0690d4208e8fe1ae0b4add6a39bdf3dc to your computer and use it in GitHub Desktop.
Shelf with a dependency-managing wrapper method
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 Shelf # without the wrapper | |
... | |
def store(book) | |
# imagine complicated logic here... | |
intermediate_result = book.storage_requirements / self.capacity | |
# imagine more complicated logic... | |
end | |
end | |
class Shelf # with wrapper | |
... | |
def store(book) | |
# imagine complicated logic here... | |
intermediate_result = storage_requirements(book) / capacity | |
# imagine more complicated logic... | |
end | |
def storage_requirements(book) | |
book.storage_requirements | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment