Permalink
Browse files

Replacing the seal() function with a simple schema.self.resolve().

  • Loading branch information...
1 parent da2771c commit 5fd4a7f0a4a629f954ecdbf9c81c72319ea5f3d1 @molnarg committed Aug 18, 2012
Showing with 9 additions and 16 deletions.
  1. +1 −9 lib/Schema.js
  2. +8 −7 lib/schema.js
View
@@ -4,19 +4,11 @@ var def = require('def.js')
var Schema = module.exports = function() {}
Schema.prototype = {
- seal : function() {
- if (this.sealed) return this.validate
- this.sealed = true
- Schema.self.resolve(this)
-
- return this.validate
- },
-
wrap : function() {
if (this.wrapped) return this.validate
this.wrapped = true
- var publicFunctions = [ 'seal', 'toJSON', 'generate', 'unwrap' ]
+ var publicFunctions = [ 'toJSON', 'generate', 'unwrap' ]
publicFunctions = publicFunctions.concat(this.publicFunctions || [])
for (var i = 0; i < publicFunctions.length; i++) {
View
@@ -16,27 +16,28 @@ var schema = module.exports = function(schemaDescription) {
return schemaObject.wrap()
} else {
- // When called as simple function, forward everything
- // to fromJS, and then seal the resulting schema
+ // When called as simple function, forward everything to fromJS
+ // and then resolve schema.self to the resulting schema object
schemaObject = Schema.fromJS(schemaDescription)
+ schema.self.resolve(schemaObject)
if (doc) schemaObject.doc = doc
- return schemaObject.wrap().seal()
+ return schemaObject.wrap()
}
}
schema.toJSON = function(sch) {
- return Schema.fromJS(sch).wrap().seal().toJSON()
+ return Schema.fromJS(sch).toJSON()
}
schema.generate = function(sch) {
- return Schema.fromJS(sch).wrap().seal().generate()
+ return Schema.fromJS(sch).generate()
}
schema.fromJS = function(sch) {
- return Schema.fromJS(sch).wrap().seal()
+ return Schema.fromJS(sch).wrap()
}
schema.fromJSON = function(sch) {
- return Schema.fromJSON(sch).wrap().seal()
+ return Schema.fromJSON(sch).wrap()
}

0 comments on commit 5fd4a7f

Please sign in to comment.