Permalink
Browse files

feat(entity): Added .getName() methods for instance and static

  • Loading branch information...
RWOverdijk committed Dec 29, 2015
1 parent 78eacbf commit f65d78fb97fd6d733c7083e2be77346639553b5b
Showing with 30 additions and 0 deletions.
  1. +30 −0 src/entity.js
@@ -178,6 +178,36 @@ export class Entity {
return this.__api.destroy(this.getResource(), this.id);
}
/**
* Get the name of the entity. This is useful for labels in texts.
*
* @return {string}
*/
getName() {
let metaName = this.getMeta().fetch('name');
if (metaName) {
return metaName;
}
return this.getResource();
}
/**
* Get the name of the entity (static). This is useful for labels in texts.
*
* @return {string}
*/
static getName() {
let metaName = OrmMetadata.forTarget(this).fetch('name');
if (metaName) {
return metaName;
}
return this.getResource();
}
/**
* Set data on this entity.
*

0 comments on commit f65d78f

Please sign in to comment.