Class: Spree::Config
- Inherits:
-
Object
- Object
- Spree::Config
- Includes:
- Singleton, PreferenceAccess
- Defined in:
- lib/spree/config.rb
Overview
Singleton class to access the configuration object (AppConfiguration.first by default) and its 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+
Spree::Config.searcher/searcher= # get/set the default product search implementation
Class Method Summary collapse
- .instance ⇒ Object
-
.searcher_class ⇒ Object
searcher_class allows spree extension writers to provide their own Search class.
- .searcher_class=(sclass) ⇒ Object
Methods included from PreferenceAccess
Class Method Details
.instance ⇒ Object
15 16 17 18 19 20 |
# File 'lib/spree/config.rb', line 15 def instance return @configuration if @configuration return nil unless ActiveRecord::Base.connection.tables.include?('configurations') @configuration ||= AppConfiguration.find_or_create_by_name("Default configuration") @configuration end |
.searcher_class ⇒ Object
searcher_class allows spree extension writers to provide their own Search class
23 24 25 |
# File 'lib/spree/config.rb', line 23 def searcher_class @searcher_class ||= Spree::Search::Base end |
.searcher_class=(sclass) ⇒ Object
27 28 29 |
# File 'lib/spree/config.rb', line 27 def searcher_class=(sclass) @searcher_class = sclass end |