Created
February 11, 2015 12:44
-
-
Save romikoops/49ec0b8a4ade2fe540ca to your computer and use it in GitHub Desktop.
design
This file contains hidden or 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
module PaymentMethods | |
class Base | |
def request_url(params) | |
raise 'Not implemented' | |
end | |
def response_notification | |
raise 'Not implemented' | |
end | |
end | |
class Skrill < Base | |
def request_url(params) | |
#some implementation | |
end | |
def response_notification | |
#some implementation | |
end | |
end | |
class Obt < Base | |
def request_url(params) | |
#some implementation | |
end | |
def response_notification | |
#some implementation | |
end | |
end | |
end | |
module PaymentProvider | |
def self.for(type) | |
if known_payment_method?(type) | |
klass = type.classify.constantize | |
"PaymentMethods::#{klass}".constantize.new | |
else | |
raise "Unknown payment method '#{type}'" | |
end | |
end | |
end | |
PaymentProvider.for(:skrill).request_url(params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment