Module xDocument
Extend xDocument to create classes with basic import/export features .
For the xDocument to work, you need to define a static DOC_PROPS property, which will define the properties which should be included in exports/imports as well as their type (number,boolean,string)
For example:
MyClass.DOC_PROPS = {
active = "boolean",
name = "string",
}
Functions
import (str) | import serialized values that match one of our DOC_PROPS |
export () | |
serialize (obj, props) | collect properties from object |
deserialize (str, props) | deserialize string |
Functions
- import (str)
-
import serialized values that match one of our DOC_PROPS
Parameters:
- str (string) serialized values
Returns:
-
string, serialized values
- export ()
-
Returns:
-
string, serialized values
- serialize (obj, props)
-
collect properties from object
Parameters:
- obj (class instance)
- props (table) DOC_PROPS
Returns:
-
table
- deserialize (str, props)
-
deserialize string
Parameters:
- str (str) serialized string
- props (table) DOC_PROPS
Returns:
-
table or nil