class Spree::Preferences::StaticModelPreferences::Definition

Attributes

preferences[R]

Public Class Methods

new(klass, hash) click to toggle source
# File lib/spree/preferences/static_model_preferences.rb, line 9
def initialize(klass, hash)
  hash = hash.symbolize_keys
  hash.keys.each do |key|
    if !klass.defined_preferences.include?(key)
      raise "Preference #{key.inspect} is not defined on #{klass}"
    end
  end
  @preferences = hash
end

Public Instance Methods

[]=(key, value) click to toggle source
# File lib/spree/preferences/static_model_preferences.rb, line 23
def []=(key, value)
  # ignores assignment
end
fetch(key, &block) click to toggle source
# File lib/spree/preferences/static_model_preferences.rb, line 19
def fetch(key, &block)
  @preferences.fetch(key, &block)
end
to_hash() click to toggle source
# File lib/spree/preferences/static_model_preferences.rb, line 27
def to_hash
  @preferences.deep_dup
end