Sha256: 1f40e55b0ba2f5fdd9a46cdc29daf0889dfa41b66f2fda3ec3f6980ac676b1a8

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 Bytes

Contents

module Pesapal

  class Railtie < Rails::Railtie

    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]
        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
      else
        config.pesapal_credentials = { :callback_url => 'http://0.0.0.0:3000/pesapal/callback',
                                       :consumer_key => '<YOUR_CONSUMER_KEY>',
                                       :consumer_secret => '<YOUR_CONSUMER_SECRET>'
                                      }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pesapal-1.5.4 lib/pesapal/railtie.rb
pesapal-1.5.3 lib/pesapal/railtie.rb
pesapal-1.5.2 lib/pesapal/railtie.rb
pesapal-1.5.1 lib/pesapal/railtie.rb