Module: User::Preferences

Included in:
User
Defined in:
app/models/user/preferences.rb

Constant Summary

BASE_PREFERENCES =
YAML.load_file(Rails.root + 'config/preferences/user.yml')

Instance Method Summary (collapse)

Instance Method Details

- (Object) fill_preferences



23
24
25
26
27
28
29
30
31
32
# File 'app/models/user/preferences.rb', line 23

def fill_preferences
  if preferences.empty?
    reset_preferences
  else
    BASE_PREFERENCES.keys.each do |k|
      preferences[k] = BASE_PREFERENCES[k] if send(k).nil?
    end
  end
  true
end

- (Object) layout=(values)



38
39
40
41
# File 'app/models/user/preferences.rb', line 38

def layout=(values)
  l = layout.nil? ? {} : layout
  super(l.merge(values))
end

- (Object) reset_preferences



34
35
36
# File 'app/models/user/preferences.rb', line 34

def reset_preferences
  write_attribute(:preferences, BASE_PREFERENCES)
end