Skip to content

Instantly share code, notes, and snippets.

@Sihui
Created August 5, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sihui/19c40cd8a8146acd24a8cfbf82362222 to your computer and use it in GitHub Desktop.
Save Sihui/19c40cd8a8146acd24a8cfbf82362222 to your computer and use it in GitHub Desktop.
Design Pattern: Composite and Group Messaging
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