Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[core] initialize properties via setters

  • Loading branch information...
commit 7ca717f0fc9d23cbf39b1231c8e36d58d11a6412 1 parent 33a3675
@indutny indutny authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/resourceful/core.js
View
9 lib/resourceful/core.js
@@ -181,11 +181,16 @@ resourceful.define = function (name, definition) {
resourceful.defineProperty = function (obj, property, schema) {
schema = schema || {};
+ // Call setter if needed
+ if (schema.set) {
+ obj.writeProperty(property, obj.readProperty(property), schema.set);
+ }
+
// Sanitize defaults and per-creation properties
if (schema.sanitize) {
- var val = obj.readProperty(property, schema.get);
+ var val = obj.readProperty(property);
if (val !== undefined) {
- obj.writeProperty(property, schema.sanitize(val), schema.set);
+ obj.writeProperty(property, schema.sanitize(val));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.