Module: Preferences::User
- Defined in:
- lib/preferences/base.rb
Constant Summary collapse
- FILE_NAME =
'preferences.yaml'
Class Method Summary collapse
- .load(namespace) ⇒ Object
- .load!(namespace) ⇒ Object
- .save!(attribs, namespace) ⇒ Object
- .user_preferences_file(namespace) ⇒ Object
- .user_preferences_path(namespace) ⇒ Object
Class Method Details
.load(namespace) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/preferences/base.rb', line 21 def self.load(namespace) begin self.load!(namespace) rescue {} end end |
.load!(namespace) ⇒ Object
17 18 19 |
# File 'lib/preferences/base.rb', line 17 def self.load!(namespace) Preferences.load(user_preferences_file(namespace)) end |
.save!(attribs, namespace) ⇒ Object
29 30 31 32 |
# File 'lib/preferences/base.rb', line 29 def self.save!(attribs, namespace) FileUtils.makedirs(user_preferences_path(namespace)) Preferences.save(attribs, user_preferences_file(namespace)) end |
.user_preferences_file(namespace) ⇒ Object
38 39 40 |
# File 'lib/preferences/base.rb', line 38 def self.user_preferences_file(namespace) File.join(user_preferences_path(namespace), FILE_NAME) end |
.user_preferences_path(namespace) ⇒ Object
34 35 36 |
# File 'lib/preferences/base.rb', line 34 def self.user_preferences_path(namespace) File.(File.join('~', '.config', namespace)) end |