Mark object instances in the device doc

This commit is contained in:
Zaid Abdulla committed 2013-07-21 10:01:43 +03:00
1 parent 690afb3522
commit 7da76e0de7
1 file changed
+10 -2
+10 -2
View File
@@ -12,6 +12,9 @@ mongodb = require 'mongodb'
fs = require 'fs'
apiFunctions = require './api-functions'
OBJECT_REGEX = /\.$/
INSTANCE_REGEX = /\.[\d]+\.$/
applyConfigurations = (currentRequest, taskList) ->
if taskList.length
@@ -83,9 +86,14 @@ updateDevice = (currentRequest, actions, callback) ->
if actions.parameterNames?
for p in actions.parameterNames
path = if common.endsWith(p[0], '.') then p[0] else "#{p[0]}."
if common.endsWith(p[0], '.')
if OBJECT_REGEX.test(p[0])
path = p[0]
if INSTANCE_REGEX.test(p[0])
updates["#{path}_instance"] = true
else
updates["#{path}_object"] = true
else
path = "#{p[0]}."
updates["#{path}_writable"] = p[1]
updates["#{path}_timestamp"] = now