Last active
August 2, 2019 11:13
-
-
Save nafidurmus/c0027d8d8e61346fcb6ad4261743b57f to your computer and use it in GitHub Desktop.
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 UIButton | |
attr_reader :command | |
def initialize(command) | |
@command = command | |
end | |
def press_button | |
@command.execute | |
end | |
end | |
class AddItemToCartCommand | |
attr_reader :item, :cart | |
def initialize(item, cart) | |
@item = item | |
@cart = cart | |
end | |
def execute | |
@cart.add_item(@item) | |
end | |
def unexecute | |
@cart.remove_item(@item) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment