File tree 1 file changed +16
-2
lines changed
vendor/hal-browser/js/hal
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ HAL.Models.Resource = Backbone.Model.extend({
2
2
initialize : function ( representation ) {
3
3
representation = representation || { } ;
4
4
this . links = representation . _links ;
5
- this . title = representation . title ;
6
- this . name = representation . name ;
5
+ this . title = this . buildTitle ( representation ) ;
6
+ this . name = this . buildName ( representation ) ;
7
7
if ( representation . _embedded !== undefined ) {
8
8
this . embeddedResources = this . buildEmbeddedResources ( representation . _embedded ) ;
9
9
}
@@ -12,6 +12,20 @@ HAL.Models.Resource = Backbone.Model.extend({
12
12
this . unset ( '_links' , { silent : true } ) ;
13
13
} ,
14
14
15
+ buildName : function ( representation ) {
16
+ return representation . name ||
17
+ ( representation . _links
18
+ && representation . _links . self
19
+ && representation . _links . self . name ) ;
20
+ } ,
21
+
22
+ buildTitle : function ( representation ) {
23
+ return representation . title ||
24
+ ( representation . _links
25
+ && representation . _links . self
26
+ && representation . _links . self . title ) ;
27
+ } ,
28
+
15
29
buildEmbeddedResources : function ( embeddedResources ) {
16
30
var result = { } ;
17
31
_ . each ( embeddedResources , function ( obj , rel ) {
You can’t perform that action at this time.
0 commit comments