|
|
@@ -13,6 +13,7 @@ var ProjectDocumentSource = module.exports = (function(){
|
|
|
if(arguments.length !== 0) throw new Error("zero args expected");
|
|
|
base.call(this);
|
|
|
this.EO = new ObjectExpression();
|
|
|
+ this._raw = undefined;
|
|
|
}, base = require('./DocumentSource'), proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
|
|
|
|
|
|
// DEPENDENCIES
|
|
|
@@ -31,6 +32,15 @@ var ProjectDocumentSource = module.exports = (function(){
|
|
|
return klass.projectName;
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the object that was used to construct the ProjectDocumentSource
|
|
|
+ *
|
|
|
+ * @return {object} the object that was used to construct the ProjectDocumentSource
|
|
|
+ **/
|
|
|
+ proto.getRaw = function getRaw() {
|
|
|
+ return this._raw;
|
|
|
+ };
|
|
|
+
|
|
|
/**
|
|
|
* Calls base document source eof()
|
|
|
*
|
|
|
@@ -53,7 +63,7 @@ var ProjectDocumentSource = module.exports = (function(){
|
|
|
/**
|
|
|
* Builds a new document(object) that represents this base document
|
|
|
*
|
|
|
- * @return A document that represents this base document
|
|
|
+ * @return {object} A document that represents this base document
|
|
|
**/
|
|
|
proto.getCurrent = function getCurrent() {
|
|
|
var inDocument = this.pSource.getCurrent();
|
|
|
@@ -92,18 +102,19 @@ var ProjectDocumentSource = module.exports = (function(){
|
|
|
* Builds a new ProjectDocumentSource from an object
|
|
|
*
|
|
|
* @method createFromJson
|
|
|
- * @return a ProjectDocumentSource instance
|
|
|
+ * @return {ProjectDocmentSource} a ProjectDocumentSource instance
|
|
|
**/
|
|
|
klass.createFromJson = function(jsonElement, expCtx) {
|
|
|
- if(jsonElement instanceof Object && jsonElement.constructor === Object) {
|
|
|
+ if(!(jsonElement instanceof Object) || jsonElement.constructor !== Object) {
|
|
|
throw new Error('Error 15969. Specification must be an object but was ' + typeof jsonElement);
|
|
|
}
|
|
|
- var objectContext = Expression.ObjectCtx({
|
|
|
+ var objectContext = new Expression.ObjectCtx({
|
|
|
isDocumentOk:true,
|
|
|
isTopLevel:true,
|
|
|
isInclusionOk:true
|
|
|
});
|
|
|
var project = new ProjectDocumentSource();
|
|
|
+ this._raw = jsonElement;
|
|
|
var parsed = Expression.parseObject(jsonElement, objectContext);
|
|
|
var exprObj = parsed;
|
|
|
if(! exprObj instanceof ObjectExpression) {
|