lib/pesapal/railtie.rb in pesapal-1.5.4 vs lib/pesapal/railtie.rb in pesapal-1.5.5
- old
+ new
@@ -1,14 +1,14 @@
module Pesapal
-
+ # Hooks Pesapal to extend Rails and/or modify the initialization process.
class Railtie < Rails::Railtie
-
+ # Loads pesapal credentials from initializer file depending on environment
+ # and fallback to default values if anything goes wrong.
initializer 'pesapal.load_credentials' do
-
path_to_yaml = "#{Rails.root}/config/pesapal.yml"
if File.exist?(path_to_yaml)
begin
- config.pesapal_credentials = YAML::load(IO.read(path_to_yaml))[Rails.env]
+ config.pesapal_credentials = YAML.load(IO.read(path_to_yaml))[Rails.env]
rescue Errno::ENOENT
logger.info('YAML configuration file couldn\'t be found.'); return
rescue Psych::SyntaxError
logger.info('YAML configuration file contains invalid syntax. Will use using defaults.'); return
end