(path, value)
| 454 | |
| 455 | // ('data.a.b', 5) => opts.data.a.b = 5 |
| 456 | var setPropertyByPath = function (path, value) { |
| 457 | if (typeof path == 'string') { |
| 458 | path = path.split('.'); |
| 459 | } else if (!Array.isArray(path)) { |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | var propName = path.shift(); |
| 464 | var prop = Model.allProperties[propName] || opts.extra[propName]; |
| 465 | var currKey, currObj; |
| 466 | |
| 467 | if (!prop) { |
| 468 | return; |
| 469 | } |
| 470 | if (path.length == 0) { |
| 471 | instance[propName] = value; |
| 472 | return; |
| 473 | } |
| 474 | currObj = instance[propName]; |
| 475 | |
| 476 | while(currObj && path.length > 0 ) { |
| 477 | currKey = path.shift(); |
| 478 | |
| 479 | if (path.length > 0) { |
| 480 | currObj = currObj[currKey]; |
| 481 | } else if (currObj[currKey] !== value) { |
| 482 | currObj[currKey] = value; |
| 483 | opts.changes.push(propName); |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | var addInstanceProperty = function (key) { |
| 489 | var defaultValue = undefined; |
nothing calls this directly
no outgoing calls
no test coverage detected