Class: Spree::Preferences::StaticModelPreferences
- Inherits:
-
Object
- Object
- Spree::Preferences::StaticModelPreferences
- Defined in:
- lib/spree/preferences/static_model_preferences.rb
Defined Under Namespace
Classes: Definition
Instance Method Summary collapse
- #add(klass, name, preferences) ⇒ Object
- #for_class(klass) ⇒ Object
-
#initialize ⇒ StaticModelPreferences
constructor
A new instance of StaticModelPreferences.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ StaticModelPreferences
Returns a new instance of StaticModelPreferences.
29 30 31 32 33 |
# File 'lib/spree/preferences/static_model_preferences.rb', line 29 def initialize @store = Hash.new do |data, klass| data[klass] = {} end end |
Instance Method Details
#add(klass, name, preferences) ⇒ Object
35 36 37 |
# File 'lib/spree/preferences/static_model_preferences.rb', line 35 def add(klass, name, preferences) @store[klass.to_s][name] = Definition.new(klass.to_s, preferences) end |
#for_class(klass) ⇒ Object
39 40 41 |
# File 'lib/spree/preferences/static_model_preferences.rb', line 39 def for_class(klass) @store[klass.to_s] end |
#validate! ⇒ Object
43 44 45 46 47 |
# File 'lib/spree/preferences/static_model_preferences.rb', line 43 def validate! @store.keys.map(&:constantize).each do |klass| validate_for_class!(klass) end end |