Sha256: a769a834c393b1fcf1a566cab8832f8ae730eed0471726b27b556a6062041ccd

Contents?: true

Size: 878 Bytes

Versions: 3

Compression:

Stored size: 878 Bytes

Contents

module Adyen
  LIVE_RAILS_ENVIRONMENTS = ['production']  

  # Setter voor the current Adyen environment. 
  # Must be either 'test' or 'live'
  def self.environment=(env)
    @environment = env
  end
  
  # Returns the current Adyen environment.
  # Returns either 'test' or 'live'.
  def self.environment(override = nil)
    override || @environment || Adyen.autodetect_environment
  end  

  # Autodetects the Adyen environment based on the RAILS_ENV constant
  def self.autodetect_environment
    (defined?(RAILS_ENV) && Adyen::LIVE_RAILS_ENVIRONMENTS.include?(RAILS_ENV.to_s.downcase)) ? 'live' : 'test'
  end
  
  # 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
    super(sym)
  end
end

require 'adyen/encoding'
require 'adyen/formatter'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wvanbergen-adyen-0.0.1 lib/adyen.rb
wvanbergen-adyen-0.1.0 lib/adyen.rb
wvanbergen-adyen-0.1.1 lib/adyen.rb