Created
April 2, 2014 18:23
-
-
Save romikoops/9940041 to your computer and use it in GitHub Desktop.
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
require 'singleton' | |
class MailgunConnector | |
include Singleton | |
attr_reader :api_key | |
def client(api_key=settings.mailgun_key) | |
if @api_key == api_key && @api_key | |
@client | |
else | |
@api_key = api_key | |
@client = Mailgun::Client.new(@api_key) | |
end | |
end | |
def domain | |
@domain || change_domain | |
end | |
def change_domain(name=settings.mailgun_domain) | |
@domain = name | |
end | |
end | |
MailgunConnector.instance.client | |
MailgunConnector.instance.domain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment