Skip to content

Instantly share code, notes, and snippets.

@romikoops
Created April 2, 2014 18:23
Show Gist options
  • Save romikoops/9940041 to your computer and use it in GitHub Desktop.
Save romikoops/9940041 to your computer and use it in GitHub Desktop.
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