text: var ObjectMaker, Q,
    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
  
  Q = use('q');
  
  ObjectMaker = (function() {
    function ObjectMaker(adapter) {
      this.adapter = adapter;
      this.array_types = ['string', 'int', 'long', 'time', 'date'];
    }
  
    ObjectMaker.prototype.makeObject = function(object) {
      var deffered;
      deffered = Q.defer();
      if (!object.id.value) {
        this.persist(object, object.getTableName()).then((function(_this) {
          return function(resultAdd) {
            return _this.createSimpleObject(resultAdd).then(function(resultPromise) {
              return deffered.resolve(resultPromise);
            });
          };
        })(this));
      } else {
        this.createSimpleObject(object).then(function(resultPromise) {
          return deffered.resolve(resultPromise);
        });
      }
      return deffered.promise;
    };
  
    ObjectMaker.prototype.createSimpleObject = function(badObject) {
      var fullObject, k, v, value, _i, _len, _ref;
      fullObject = {};
      for (k in badObject) {
        v = badObject[k];
        if (this.isSimpleProperty(k, v)) {
          fullObject[k] = v.value;
        } else {
          if (this.isObject(v)) {
            if (!this.isArray(v)) {
              this.persist(this.createRefObject(v), v.type).then(function(resultAdd) {
                return fullObject[k] = resultAdd;
              });
            } else {
              fullObject[k] = [];
              _ref = v.value;
              for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                value = _ref[_i];
                console.log(this.createRefObject(value));
                this.persist(this.createRefObject(value), value.type).then(function(resultAdd) {
                  return fullObject[k].push(resultAdd);
                });
              }
            }
          }
        }
      }
      return fullObject;
    };
  
    ObjectMaker.prototype.createRefObject = function(badObject) {
      return {
        $ref: badObject.type,
        $id: badObject.id.value
      };
    };
  
    ObjectMaker.prototype.persist = function(object, type) {
      var deffered;
      deffered = Q.defer();
      this.adapter.add(type, object).then(function(result) {
        return console.log(result);
      });
      return deffered.promise;
    };
  
    ObjectMaker.prototype.isSimpleProperty = function(k, v) {
      if (!this.isProp(k, 'repository')) {
        if (!this.isIgnorable(v)) {
          if (this.inMyArray(v)) {
            return true;
          }
        }
      }
      return false;
    };
  
    ObjectMaker.prototype.isObject = function(object) {
      if (typeof object === 'object') {
        return true;
      }
    };
  
    ObjectMaker.prototype.inMyArray = function(object) {
      var _ref;
      if (_ref = object.type, __indexOf.call(this.array_types, _ref) >= 0) {
        return true;
      }
      return false;
    };
  
    ObjectMaker.prototype.isArray = function(object) {
      return Array.isArray(object.value);
    };
  
    ObjectMaker.prototype.isProp = function(k, p) {
      if (k === p) {
        return true;
      }
      return false;
    };
  
    ObjectMaker.prototype.isIgnorable = function(object) {
      if (object['dbIgnore']) {
        return true;
      }
      return false;
    };
  
    return ObjectMaker;
  
  })();
  
  module.exports = ObjectMaker;
  