Class: Spree::Paypal::Config

Inherits:
Object
  • Object
show all
Includes:
PreferenceAccess, Singleton
Defined in:
lib/spree/paypal/config.rb

Overview

Singleton class to access the Paypal configuration object (PaypalConfiguration.first by default) and it’s preferences.

Usage:

Spree::Paypal::Config[:foo]                  # Returns the foo preference
Spree::Paypal::Config[]                      # Returns a Hash with all the tax preferences
Spree::Paypal::Config.instance               # Returns the configuration object (PaypalConfiguration.first)
Spree::Paypal::Config.set(preferences_hash)  # Set the tax preferences as especified in +preference_hash+

Class Method Summary collapse

Class Method Details

.instanceObject



15
16
17
18
# File 'lib/spree/paypal/config.rb', line 15

def instance
  return nil unless ActiveRecord::Base.connection.tables.include?('configurations')
  PaypalConfiguration.find_or_create_by_name("Default paypal configuration")
end