Class: Spree::GoogleBase::Config

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

Overview

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

Usage:

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

Class Method Summary collapse

Class Method Details

.instanceObject



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

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