Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Sihui
Created August 6, 2017 23:17
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/93f72308838c8124d786148ac147b570 to your computer and use it in GitHub Desktop.
Save Sihui/93f72308838c8124d786148ac147b570 to your computer and use it in GitHub Desktop.
Design Pattern: Proxy and Agent
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