@@ -14,11 +14,60 @@ const {
14
14
* A wrapper object for ember object properties
15
15
*/
16
16
class EOProp {
17
- constructor ( eoProp ) {
17
+ constructor ( eoProp , runtimeData , importedDecoratedProps ) {
18
18
this . _prop = eoProp ;
19
19
this . decorators = [ ] ;
20
20
this . modifiers = [ ] ;
21
21
this . decoratorArgs = { } ;
22
+
23
+ if ( runtimeData . type ) {
24
+ const {
25
+ type,
26
+ computedProperties = [ ] ,
27
+ offProperties = { } ,
28
+ overriddenActions = [ ] ,
29
+ overriddenProperties = [ ] ,
30
+ unobservedProperties = { } ,
31
+ } = runtimeData ;
32
+
33
+ this . emberType = type ;
34
+
35
+ const name = this . name ;
36
+ if ( Object . keys ( unobservedProperties ) . includes ( name ) ) {
37
+ this . decorators . push ( { name : 'unobserves' } ) ;
38
+ this . decoratorArgs [ 'unobserves' ] = unobservedProperties [ name ] ;
39
+ }
40
+ if ( Object . keys ( offProperties ) . includes ( name ) ) {
41
+ this . decorators . push ( { name : 'off' } ) ;
42
+ this . decoratorArgs [ 'off' ] = offProperties [ name ] ;
43
+ }
44
+ if ( computedProperties . includes ( name ) ) {
45
+ this . isComputed = true ;
46
+ }
47
+ if ( this . isActions ) {
48
+ this . overriddenActions = overriddenActions ;
49
+ }
50
+ this . isOverridden = overriddenProperties . includes ( name ) ;
51
+ this . runtimeType = type ;
52
+ }
53
+
54
+ if ( this . isCallExpression ) {
55
+ let calleeObject = get ( this . _prop , 'value' ) ;
56
+ const modifiers = [ getModifier ( calleeObject ) ] ;
57
+ while ( get ( calleeObject , 'callee.type' ) === 'MemberExpression' ) {
58
+ calleeObject = get ( calleeObject , 'callee.object' ) ;
59
+ modifiers . push ( getModifier ( calleeObject ) ) ;
60
+ }
61
+ this . calleeObject = calleeObject ;
62
+ this . modifiers = modifiers . reverse ( ) ;
63
+ this . modifiers . shift ( ) ;
64
+
65
+ if ( importedDecoratedProps [ this . calleeName ] ) {
66
+ this . decorators . push ( importedDecoratedProps [ this . calleeName ] ) ;
67
+ } else if ( this . isComputed ) {
68
+ this . decorators . push ( { name : this . calleeName } ) ;
69
+ }
70
+ }
22
71
}
23
72
24
73
get value ( ) {
@@ -131,16 +180,16 @@ class EOProp {
131
180
return this . name === 'classNames' ;
132
181
}
133
182
134
- get isAction ( ) {
135
- return this . name === 'actions ' ;
183
+ get isClassNameBindings ( ) {
184
+ return this . name === 'classNameBindings ' ;
136
185
}
137
186
138
- get hasClassNameDecorator ( ) {
139
- return this . decoratorNames . includes ( 'className' ) ;
187
+ get isAttributeBindings ( ) {
188
+ return this . name === 'attributeBindings' ;
140
189
}
141
190
142
- get hasAttributeDecorator ( ) {
143
- return this . decoratorNames . includes ( 'attribute' ) ;
191
+ get isActions ( ) {
192
+ return this . name === 'actions' ;
144
193
}
145
194
146
195
get hasUnobservesDecorator ( ) {
@@ -162,74 +211,6 @@ class EOProp {
162
211
get hasMetaDecorator ( ) {
163
212
return this . decorators . find ( d => d . isMetaDecorator ) ;
164
213
}
165
-
166
- setCallExpressionProps ( ) {
167
- let calleeObject = get ( this . _prop , 'value' ) ;
168
- const modifiers = [ getModifier ( calleeObject ) ] ;
169
- while ( get ( calleeObject , 'callee.type' ) === 'MemberExpression' ) {
170
- calleeObject = get ( calleeObject , 'callee.object' ) ;
171
- modifiers . push ( getModifier ( calleeObject ) ) ;
172
- }
173
- this . calleeObject = calleeObject ;
174
- this . modifiers = modifiers . reverse ( ) ;
175
- this . modifiers . shift ( ) ;
176
- }
177
-
178
- setDecorators ( importedDecoratedProps ) {
179
- if ( this . isCallExpression ) {
180
- this . setCallExpressionProps ( ) ;
181
-
182
- if ( importedDecoratedProps [ this . calleeName ] ) {
183
- this . decorators . push ( importedDecoratedProps [ this . calleeName ] ) ;
184
- } else if ( this . isComputed ) {
185
- this . decorators . push ( { name : this . calleeName } ) ;
186
- }
187
- }
188
- }
189
-
190
- addBindingProps ( attributeBindingsProps , classNameBindingsProps ) {
191
- if ( attributeBindingsProps [ this . name ] ) {
192
- this . decorators . push ( { name : 'attribute' } ) ;
193
- this . propList = attributeBindingsProps [ this . name ] ;
194
- } else if ( classNameBindingsProps [ this . name ] ) {
195
- this . decorators . push ( { name : 'className' } ) ;
196
- this . propList = classNameBindingsProps [ this . name ] ;
197
- }
198
- }
199
-
200
- setRuntimeData ( {
201
- computedProperties = [ ] ,
202
- // observedProperties = [],
203
- // observerProperties = {},
204
- offProperties = { } ,
205
- overriddenActions = [ ] ,
206
- overriddenProperties = [ ] ,
207
- // ownProperties = [],
208
- type = '' ,
209
- unobservedProperties = { } ,
210
- } ) {
211
- if ( ! type ) {
212
- return ;
213
- }
214
-
215
- const name = this . name ;
216
- if ( Object . keys ( unobservedProperties ) . includes ( name ) ) {
217
- this . decorators . push ( { name : 'unobserves' } ) ;
218
- this . decoratorArgs [ 'unobserves' ] = unobservedProperties [ name ] ;
219
- }
220
- if ( Object . keys ( offProperties ) . includes ( name ) ) {
221
- this . decorators . push ( { name : 'off' } ) ;
222
- this . decoratorArgs [ 'off' ] = offProperties [ name ] ;
223
- }
224
- if ( computedProperties . includes ( name ) ) {
225
- this . isComputed = true ;
226
- }
227
- if ( this . isAction ) {
228
- this . overriddenActions = overriddenActions ;
229
- }
230
- this . isOverridden = overriddenProperties . includes ( name ) ;
231
- this . runtimeType = type ;
232
- }
233
214
}
234
215
235
216
module . exports = EOProp ;
0 commit comments