Class: Spree::Preferences::StaticModelPreferences

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/preferences/static_model_preferences.rb

Defined Under Namespace

Classes: Definition

Instance Method Summary (collapse)

Constructor Details

- (StaticModelPreferences) initialize

Returns a new instance of StaticModelPreferences



30
31
32
33
34
# File 'app/models/spree/preferences/static_model_preferences.rb', line 30

def initialize
  @store = Hash.new do |h, klass|
    h[klass] = {}
  end
end

Instance Method Details

- (Object) add(klass, name, preferences)



36
37
38
39
40
# File 'app/models/spree/preferences/static_model_preferences.rb', line 36

def add(klass, name, preferences)
  # We use class name instead of class to allow reloading in dev
  raise "Static model preference '#{name}' on #{klass} is already defined" if @store[klass.to_s][name]
  @store[klass.to_s][name] = Definition.new(klass, preferences)
end

- (Object) for_class(klass)



42
43
44
# File 'app/models/spree/preferences/static_model_preferences.rb', line 42

def for_class(klass)
  @store[klass.to_s]
end