Skip to content

Instantly share code, notes, and snippets.

@mjalvarez
mjalvarez / chain-of-responsibility.rb
Created January 31, 2017 14:22 — forked from martindemello/chain-of-responsibility.rb
chain of responsibility example in ruby
class PurchaseApprover
# Implements the chain of responsibility pattern. Does not know anything
# about the approval process, merely whether the current handler can approve
# the request, or must pass it to a successor.
attr_reader :successor
def initialize successor
@successor = successor
end