/
Object.js
56 lines (35 loc) · 1.23 KB
/
Object.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Class('KiokuJS.TypeMap.Object', {
isa : 'KiokuJS.TypeMap',
does : 'KiokuJS.TypeMap.Role.NoDeps',
has : {
forClass : 'Object',
passThrough : true
},
methods : {
canHandle : function (className) {
return className == 'Object'
},
collapse : function (node, collapser) {
var data = {}
Joose.O.eachOwn(node.object, function (value, name) {
data[ name ] = collapser.visit(value)
})
return data
},
clearInstance : function (node) {
var instance = node.object
Joose.O.eachOwn(node.object, function (value, name) {
delete instance[ name ]
})
},
createEmptyInstance : function (node) {
return {}
},
populate : function (node, expander) {
var instance = node.object
Joose.O.each(node.data, function (value, name) {
instance[ name ] = expander.visit(value)
})
}
}
})