Skip to content

Instantly share code, notes, and snippets.

@nelhage
Created April 1, 2014 22:22
Show Gist options
  • Save nelhage/9924340 to your computer and use it in GitHub Desktop.
Save nelhage/9924340 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
class Charge
def visit(obj, method, *args)
obj.public_send(:"#{method}_for_charge", args)
end
end
class Refund
def visit(obj, method, *args)
obj.public_send(:"#{method}_for_refund", args)
end
end
module FeeCalculator
def self.fees_for(obj)
obj.visit("fees", self)
end
def self.fees_for_charge(ch)
# …
end
def self.fees_for_refund(re)
# …
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment