module Exact class Credentials attr_accessor :config def initialize load_configuration(ENV['LOCATION']) end # obtain the credentials for the processor specified by # ENV['PROCESSOR'], defaulting to 'emergis' def current_gateway processor = ENV['PROCESSOR'] || 'emergis' self.config[processor] end def chase self.config['chase'] end def chase_batch self.config['chase_batch'] end def chase? [self.chase[:gateway_id], self.chase_batch[:gateway_id]].include?(current_gateway[:gateway_id]) end def tsys self.config['tsys'] end def tsys? current_gateway[:gateway_id] == self.tsys[:gateway_id] end def emergis self.config['emergis'] end def emergis? current_gateway[:gateway_id] == self.emergis[:gateway_id] end def moneris self.config['moneris'] end def moneris? current_gateway[:gateway_id] == self.moneris[:gateway_id] end def load_configuration(environment) config_file = File.dirname(__FILE__) + '/credentials.yml' yaml = YAML::load(IO.read(config_file)) environment ||= 'DEV' self.config = yaml[environment] if self.config.nil? abort "No credentials configured. Please create a properly-formatted credentials.yml file in #{File.dirname(__FILE__)}." end end private :load_configuration end end