@@ -4,7 +4,7 @@ define(function (require) {
4
4
GenericUriModel = require ( 'entities/api/call/genericUri.model' ) ,
5
5
SampleUriModel = require ( 'entities/api/call/sampleUri.model' ) ,
6
6
GetUriModel = require ( 'entities/api/call/tryUri.model' ) ,
7
- HasNestedModel = require ( 'lib/hasNestedModel.mixin ' ) ,
7
+ HasNestedModel = require ( 'lib/hasNestedModel' ) ,
8
8
appChannel = require ( 'app.channel' ) ,
9
9
ApiModel ;
10
10
@@ -34,43 +34,46 @@ define(function (require) {
34
34
}
35
35
} ,
36
36
37
- constructor : function ( attrs , options ) {
38
- var apiAttributes = _ . pick ( attrs , [ 'serviceKey' , 'endpointKey' ] ) ;
39
-
40
- // Initialize submodels
41
- _ . extend ( attrs , {
42
- genericOutput : new GenericOutputModel ( apiAttributes ) ,
43
- genericUri : new GenericUriModel ( apiAttributes ) ,
44
- sampleUri : new SampleUriModel ( apiAttributes ) ,
45
- tryUri : new GetUriModel ( )
46
- } ) ;
47
-
37
+ constructor : function ( ) {
48
38
// Attach nested model functionality
49
39
new HasNestedModel ( this ) ;
50
40
51
- ApiModel . __super__ . constructor . call ( this , attrs , options ) ;
41
+ // Attach computed field functionality
42
+ new Backbone . ComputedFields ( this ) ;
43
+
44
+ ApiModel . __super__ . constructor . apply ( this , arguments ) ;
52
45
} ,
53
46
54
47
initialize : function ( ) {
55
- var self = this ;
48
+ var self = this ,
49
+ apiAttributes = {
50
+ serviceKey : this . get ( 'serviceKey' ) ,
51
+ endpointKey : this . get ( 'endpointKey' )
52
+ } ;
56
53
57
- // Attach computed fields functionality
58
- new Backbone . ComputedFields ( this ) ;
54
+ // Initialize submodels
55
+ this . set ( {
56
+ genericOutput : new GenericOutputModel ( apiAttributes ) ,
57
+ genericUri : new GenericUriModel ( apiAttributes ) ,
58
+ sampleUri : new SampleUriModel ( apiAttributes ) ,
59
+ tryUri : new GetUriModel ( )
60
+ } ) ;
59
61
60
62
this . on ( 'change' , function ( ) {
61
- var serviceKey ,
62
- endpointKey ;
63
-
63
+ var apiAttributes ;
64
+
64
65
// When serviceKey or endpointKey are changed, pass them down to submodels
65
66
if ( self . hasChanged ( 'serviceKey' ) || self . hasChanged ( 'endpointKey' ) ) {
66
- serviceKey = self . get ( 'serviceKey' ) ;
67
- endpointKey = self . get ( 'endpointKey' ) ;
67
+ apiAttributes = {
68
+ serviceKey : self . get ( 'serviceKey' ) ,
69
+ endpointKey : self . get ( 'endpointKey' )
70
+ } ;
68
71
69
72
_ . invoke ( [
70
73
self . get ( 'genericOutput' ) ,
71
74
self . get ( 'genericUri' ) ,
72
75
self . get ( 'sampleUri' )
73
- ] , 'set' , { serviceKey : serviceKey , endpointKey : endpointKey } ) ;
76
+ ] , 'set' , apiAttributes ) ;
74
77
}
75
78
} ) ;
76
79
} ,
0 commit comments