Instantly share code, notes, and snippets.

Embed
What would you like to do?
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