Class: Spree::Config

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

Overview

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

Usage:

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

Class Method Summary collapse

Methods included from PreferenceAccess

included

Class Method Details

.instanceObject



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

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