diff --git a/lib/offsite_payments.rb b/lib/offsite_payments.rb index 7151c9ef..7255b520 100644 --- a/lib/offsite_payments.rb +++ b/lib/offsite_payments.rb @@ -32,6 +32,11 @@ def self.integration(name) Integrations.const_get("#{name.to_s.downcase}".camelize) end + def self.eager_load! + Integrations.eager_load! + nil + end + mattr_accessor :mode self.mode = :production @@ -42,3 +47,5 @@ def self.test? CURRENCIES_WITHOUT_FRACTIONS = [ 'BIF', 'BYR', 'CLP', 'CVE', 'DJF', 'GNF', 'ISK', 'JPY', 'KMF', 'KRW', 'PYG', 'RWF', 'TWD', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF' ] end + +require "offsite_payments/railtie" if defined? Rails::Railtie diff --git a/lib/offsite_payments/integrations.rb b/lib/offsite_payments/integrations.rb index 6b483ce5..7b3e78b0 100644 --- a/lib/offsite_payments/integrations.rb +++ b/lib/offsite_payments/integrations.rb @@ -10,5 +10,12 @@ module Integrations # Register for autoloading autoload integration_class, f end + + def self.eager_load! + constants.each do |const_name| + const_get(const_name) + end + nil + end end end diff --git a/lib/offsite_payments/railtie.rb b/lib/offsite_payments/railtie.rb new file mode 100644 index 00000000..9daed768 --- /dev/null +++ b/lib/offsite_payments/railtie.rb @@ -0,0 +1,7 @@ +module OffsitePayments + class Railtie < Rails::Railtie + config.before_eager_load do + config.eager_load_namespace << OffsitePayments + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index c025e8b7..07abce6d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,6 +9,7 @@ require 'json' require 'nokogiri' +require 'active_support' require 'active_support/core_ext/integer/time' require 'active_support/core_ext/numeric/time' require 'active_support/core_ext/time/acts_like'