Extract _.setValueForKeyPath to underscore extensions

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-01-10 18:02:55 -07:00
parent b307bcc0de
commit ac3c059246
2 changed files with 9 additions and 8 deletions

View File

@@ -47,14 +47,7 @@ class Config
_.valueForKeyPath(@defaultSettings, keyPath)
set: (keyPath, value) ->
keys = keyPath.split('.')
hash = @settings
while keys.length > 1
key = keys.shift()
hash[key] ?= {}
hash = hash[key]
hash[keys.shift()] = value
_.setValueForKeyPath(@settings, keyPath, value)
@update()
value