lib/adyen.rb in adyen-0.2.2 vs lib/adyen.rb in adyen-0.2.3

- old
+ new

@@ -1,6 +1,29 @@ module Adyen + + # Loads configuration settings from a Hash. + # + # This method is called recursively for every module. The second + # argument is used to denote the current working module. + def self.load_config(hash, mod = Adyen) + hash.each do |key, value| + if key.to_s =~ /^[a-z]/ && mod.respond_to?(:"#{key}=") + mod.send(:"#{key}=", value) + elsif key.to_s =~ /^[A-Z]/ + begin + submodule = mod.const_get(key) + rescue LoadError => e + raise "Unknown Adyen module to configure: #{mod.name}::#{key}" + end + self.load_config(value, submodule) + else + raise "Unknown configuration variable: '#{key}' for #{mod}" + end + end + end + + # The Rails environment for which to use to Adyen "live" environment. LIVE_RAILS_ENVIRONMENTS = ['production'] # Setter voor the current Adyen environment. # Must be either 'test' or 'live' def self.environment=(env) @@ -20,10 +43,10 @@ # Loads submodules on demand, so that dependencies are not required. def self.const_missing(sym) require "adyen/#{sym.to_s.downcase}" return Adyen.const_get(sym) - rescue + rescue Exception => e super(sym) end end require 'adyen/encoding'