Don't store config values that equal their default config value

If 'foo' has not been set and has a default value of 1, 
config.set('foo', 1) will not store the 1.

If 'foo' has been set to X and has a default value of 1, 
config.set('foo', 1) will remove 'foo' from config
This commit is contained in:
probablycorey
2013-05-02 11:35:13 -07:00
parent d294bf4d05
commit 70191ea368
2 changed files with 22 additions and 4 deletions

View File

@@ -127,8 +127,10 @@ class Config
#
# Returns the `value`.
set: (keyPath, value) ->
_.setValueForKeyPath(@settings, keyPath, value)
@update()
if @get(keyPath) != value
value = undefined if _.valueForKeyPath(@defaultSettings, keyPath) == value
_.setValueForKeyPath(@settings, keyPath, value)
@update()
value
setDefaults: (keyPath, defaults) ->