Created
August 5, 2017 18:19
-
-
Save Sihui/19c40cd8a8146acd24a8cfbf82362222 to your computer and use it in GitHub Desktop.
Design Pattern: Composite and Group Messaging
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 GroupContact | |
attr_reader :group | |
def initialize(people_in_group) | |
@group = people_in_group | |
end | |
def message(text) | |
group.each do |person| | |
person.message(text) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment