Created
August 6, 2017 23:17
-
-
Save Sihui/93f72308838c8124d786148ac147b570 to your computer and use it in GitHub Desktop.
Design Pattern: Proxy and Agent
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 ActorProxy | |
attr_reader :schedule, :preference, :actor | |
def initialize(schedule, preference, actor) | |
@schedule = schedule | |
@preference = preference | |
@actor = actor | |
end | |
def handle(request) | |
return 'Sorry, blah blah blah' unless | |
schedule.fit(request) && preference.fit(request) | |
if actor.wants_to_take(request) | |
'We would love to take the opportunity! blah blah blah' | |
else | |
'Sorry, blah blah blah' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment