summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-07-04 15:35:39 +0200
committerAzul <azul@leap.se>2014-07-05 10:21:07 +0200
commitaddab2e939935201bb5a7d7a2070a3d340f8d376 (patch)
tree9fc38ae3de6d5774bc58fb80f5e6ac20f81803ce
parentb5651032152236609d8761fd464f8e04fc5797c2 (diff)
move braintree initilializer into core
it needs APP_CONFIG to be loaded and was failing due to that. Also this sets up some configuration options. They might only be needed if the billing engine is used but they should not be nested in there never the less.
-rw-r--r--config/initializers/braintree.rb26
-rw-r--r--engines/billing/config/initializers/braintree.rb23
2 files changed, 26 insertions, 23 deletions
diff --git a/config/initializers/braintree.rb b/config/initializers/braintree.rb
new file mode 100644
index 0000000..1eeb393
--- /dev/null
+++ b/config/initializers/braintree.rb
@@ -0,0 +1,26 @@
+if defined? Braintree
+
+ #
+ # set logger
+ #
+ if APP_CONFIG[:logfile].blank?
+ require 'syslog/logger'
+ Braintree::Configuration.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new('webapp'))
+ else
+ Braintree::Configuration.logger = Logger.new('log/braintree.log')
+ end
+
+ #
+ # You can set these per environment in config/config.yml:
+ #
+ # Environment must be one of: :development, :qa, :sandbox, :production
+ #
+ if billing = APP_CONFIG[:billing]
+ if braintree = billing[:braintree]
+ Braintree::Configuration.environment = braintree[:environment].downcase.to_sym
+ Braintree::Configuration.merchant_id = braintree[:merchant_id]
+ Braintree::Configuration.public_key = braintree[:public_key]
+ Braintree::Configuration.private_key = braintree[:private_key]
+ end
+ end
+end
diff --git a/engines/billing/config/initializers/braintree.rb b/engines/billing/config/initializers/braintree.rb
deleted file mode 100644
index 3d87f4c..0000000
--- a/engines/billing/config/initializers/braintree.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# set logger
-#
-if APP_CONFIG[:logfile].blank?
- require 'syslog/logger'
- Braintree::Configuration.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new('webapp'))
-else
- Braintree::Configuration.logger = Logger.new('log/braintree.log')
-end
-
-#
-# You can set these per environment in config/config.yml:
-#
-# Environment must be one of: :development, :qa, :sandbox, :production
-#
-if billing = APP_CONFIG[:billing]
- if braintree = billing[:braintree]
- Braintree::Configuration.environment = braintree[:environment].downcase.to_sym
- Braintree::Configuration.merchant_id = braintree[:merchant_id]
- Braintree::Configuration.public_key = braintree[:public_key]
- Braintree::Configuration.private_key = braintree[:private_key]
- end
-end