Permalink
Browse files

Fixes preference access problems

  • Loading branch information...
1 parent 4dd8cd8 commit 0b2f684b2968d69e7a33257222c1163a529f37ce @LBRapid LBRapid committed Dec 6, 2011
@@ -1,3 +1,3 @@
-class RecentlyViewedConfiguration < Spree::Configuration
+class Spree::RecentlyViewedConfiguration < Spree::Preferences::Configuration
preference :recently_viewed_products_max_count, :integer, :default => 5
end
@@ -1,22 +0,0 @@
-module Spree
- module RecentlyViewed
- # Singleton class to access the shipping configuration object (RecentlyViewedConfiguration.first by default) and it's preferences.
- #
- # Usage:
- # Spree::RecentlyViewed::Config[:foo] # Returns the foo preference
- # Spree::RecentlyViewed::Config[] # Returns a Hash with all the tax preferences
- # Spree::RecentlyViewed::Config.instance # Returns the configuration object (RecentlyViewedConfiguration.first)
- # Spree::RecentlyViewed::Config.set(preferences_hash) # Set the active shipping preferences as especified in +preference_hash+
- class Config
- include Singleton
- include PreferenceAccess
-
- class << self
- def instance
- return nil unless ActiveRecord::Base.connection.tables.include?('spree_configurations')
- RecentlyViewedConfiguration.find_or_create_by_name("Default recently_viewed configuration")
- end
- end
- end
- end
-end
@@ -1,20 +1,22 @@
require 'spree_core'
+module Spree::RecentlyViewed
+end
+
module SpreeRecentlyViewed
class Engine < Rails::Engine
railtie_name "spree_recently_viewed"
config.autoload_paths += %W(#{config.root}/lib)
+ initializer "spree.recently_viewed.preferences", :after => "spree.environment" do |app|
+ Spree::RecentlyViewed::Config = Spree::RecentlyViewedConfiguration.new
+ end
+
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
Rails.application.config.cache_classes ? require(c) : load(c)
end
-
- Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/*.rb")) do |c|
- Rails.application.config.cache_classes ? require(c) : load(c)
- end
-
end
config.to_prepare &method(:activate).to_proc

0 comments on commit 0b2f684

Please sign in to comment.