Skip to content

Commit

Permalink
Other: Added infrastructure for custom wrapping/unwrapping of special…
Browse files Browse the repository at this point in the history
… types, see #677
  • Loading branch information
dcodeIO committed Apr 11, 2017
1 parent 3939667 commit 0c6e639
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,15 @@ common("any", {
type: "bytes",
id: 2
}
}
}/*,
options: Object.create({
__fromObject: function(object) {
return this.fromObject(object);
},
__toObject: function(options) {
return this.toObject(options);
}
})*/
}
});

Expand Down
6 changes: 5 additions & 1 deletion src/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,18 @@ Type.prototype.setup = function setup() {
types : types,
util : util
});
this.fromObject = this.from = converter.fromObject(this).eof(fullName + "$fromObject", {
this.fromObject = converter.fromObject(this).eof(fullName + "$fromObject", {
types : types,
util : util
});
if (this.options && this.options.__formObject)
this.fromObject = this.options.__formObject.bind({ fromObject: this.fromObject });
this.toObject = converter.toObject(this).eof(fullName + "$toObject", {
types : types,
util : util
});
if (this.options && this.options.__toObject)
this.toObject = this.options.__toObject.bind({ toObject: this.toObject });
return this;
};

Expand Down

0 comments on commit 0c6e639

Please sign in to comment.