Skip to content

Instantly share code, notes, and snippets.

@r38y
Created September 5, 2013 18:24
Show Gist options
  • Save r38y/d6721f4238f3ac98b3b6 to your computer and use it in GitHub Desktop.
Save r38y/d6721f4238f3ac98b3b6 to your computer and use it in GitHub Desktop.
class Publisher < ActiveRecord::Base
def with_braintree
self.class.braintree_mutex.synchronize do
setup_braintree
yield
end
end
def setup_braintree
Braintree::Configuration.environment = CONFIG.braintree_environment
Braintree::Configuration.merchant_id = merchant_id
Braintree::Configuration.public_key = public_key
Braintree::Configuration.private_key = private_key
end
private
def self.braintree_mutex
@braintree_mutex ||= Mutex.new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment