Module: Adyen

Defined in:
lib/adyen.rb,
lib/adyen/api.rb,
lib/adyen/api.rb,
lib/adyen/form.rb,
lib/adyen/encoding.rb,
lib/adyen/matchers.rb,
lib/adyen/formatter.rb,
lib/adyen/notification.rb

Overview

XML template constants

Defined Under Namespace

Modules: API, Encoding, Form, Formatter, Matchers Classes: Notification

Constant Summary collapse

VERSION =

Version constant for the Adyen plugin. DO NOT CHANGE THIS VALUE BY HAND. It will be updated automatically by the gem:release rake task.

"0.3.8.20101015"
LIVE_RAILS_ENVIRONMENTS =

The Rails environment for which to use to Adyen “live” environment.

['production']

Class Method Summary collapse

Class Method Details

.autodetect_environment'test', 'live'

Autodetects the Adyen environment based on the RAILS_ENV constant.

Returns:

  • ('test', 'live')

    The Adyen environment that corresponds to the Rails environment



60
61
62
# File 'lib/adyen.rb', line 60

def self.autodetect_environment
  (defined?(RAILS_ENV) && Adyen::LIVE_RAILS_ENVIRONMENTS.include?(RAILS_ENV.to_s.downcase)) ? 'live' : 'test'
end

.const_missing(sym) ⇒ Module

Loads submodules on demand, so that dependencies are not required.

Parameters:

  • sym (Symbol)

    The name of the submodule

Returns:

  • (Module)

    The actual loaded submodule.

Raises:

  • (LoadError, NameError)

    If the submodule cannot be loaded



68
69
70
71
72
73
# File 'lib/adyen.rb', line 68

def self.const_missing(sym)
  require "adyen/#{sym.to_s.downcase}"
  return Adyen.const_get(sym)
rescue Exception
  super(sym)
end

.environment(override = nil) ⇒ 'test', 'live'

Returns the current Adyen environment, either test or live.

It will return the override value if set, it will return the value set using environment= otherwise. If this value also isn’t set, the environment is determined with autodetect_environment.

Parameters:

  • override ('test', 'live') (defaults to: nil)

    An environment to override the default with.

Returns:

  • ('test', 'live')

    The Adyen environment that is currently being used.



54
55
56
# File 'lib/adyen.rb', line 54

def self.environment(override = nil)
  override || @environment || Adyen.autodetect_environment
end

.environment=(env) ⇒ Object

Setter voor the current Adyen environment.

Parameters:

  • env ('test', 'live')

    The Adyen environment to use



42
43
44
# File 'lib/adyen.rb', line 42

def self.environment=(env)
  @environment = env
end

.load_config(hash, mod = Adyen) ⇒ Object

Loads configuration settings from a Hash.

Parameters:

  • hash (Hash)

    The (nested Hash) with configuration variables.

  • mod (Module) (defaults to: Adyen)

    The current working module. This parameter is used to recursively traverse the hash for submodules.

Raises:

  • (StandardError)

    An exception is raised of an unkown configuration setting is encountered in the hash.



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/adyen.rb', line 25

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]/
      self.load_config(value, mod.const_get(key))
    else
      raise "Unknown configuration variable: '#{key}' for #{mod}"
    end
  end
end