Skip to content

Commit

Permalink
fix(shape): Fixes issue with static property that is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Nov 19, 2015
1 parent 0d3dd5d commit 23ae97e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/shapes/Shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
* }
*/
export class Shape {
static name = 'Shape';

_name = 'Shape';
_text = '';
_width = 15;
_height = 5;
Expand Down Expand Up @@ -53,6 +52,15 @@ export class Shape {
this.setForeground(foreground);
}

/**
* Get name of the shape.
*
* @returns {String}
*/
getName() {
return this._name;
}

/**
* Get text content from this shape.
*
Expand Down Expand Up @@ -194,7 +202,7 @@ export class Shape {
*/
toObject() {
return {
name: Shape.name,
name: this.getName(),
options: {
text: this.getText(),
width: this.getWidth(),
Expand Down Expand Up @@ -235,7 +243,6 @@ export class Shape {
*/
static fromObject(obj) {
if (!obj.name || !obj.options) throw new Error('It looks like it is not an Object representation of the Shape');
if (obj.name !== Shape.name) throw new Error('You are trying to create Shape from Object representation of another Shape');

return new this(obj.options);
}
Expand Down

0 comments on commit 23ae97e

Please sign in to comment.