diff --git a/lib/adapter.js b/lib/adapter.js index 2dec92b..2ff1dc1 100644 --- a/lib/adapter.js +++ b/lib/adapter.js @@ -46,7 +46,22 @@ Adapter.prototype.unsubscribeAll = function() { Adapter.prototype.set = function(prop, val) { var obj = this.obj; + var parts = prop.split('.') + var part = parts.shift() if (!obj) return; + + // split property on '.' access + // and dig into the object + while (parts.length) { + // create the nested property if it doesn't exist + if (obj[part] === undefined) { + obj[part] = {}; + } + + obj = obj[part]; + part = prop = parts.shift(); + }; + if ('function' == typeof obj[prop]) { obj[prop](val); }