Set an individual model on the internal scope after wrapping it with a shield
@param {bookshelfModel} Model is a bookshelf Model constructor
@return null;
339101
function setModel(Model, modelName) {
    let authConfigs;
    if (!internals.acl) {
        throw new Error('Attempt to shield model before setting acl');
    }

    if (!internals.authConfig.length) {
        throw new Error('Attempt to shield model before seting configs');
    }

    // raise shield around Model
    new Shield(Model, internals.acl);
    authConfigs = getAuthConfigs(modelName);
    _.each(authConfigs, _.bind(Model.shield.addRules, Model.shield));
    internals.models[modelName] = Model;
}
567902
function(model) {

    const modelPrev = model.collection.prev(model);
    const modelNext = model.collection.next(model);
    let mPrevSel, mNextSel;
    if ((typeof modelPrev !== "undefined" && modelPrev !== null)) { mPrevSel = this._getSelection(modelPrev); }
    if ((typeof modelNext !== "undefined" && modelNext !== null)) { mNextSel = this._getSelection(modelNext); }
    return [mPrevSel,mNextSel];
  }
968269
function ( model ) {
                var trailing = this.collection.trailing && this.collection.trailing.id || this.collection.first().id,
                    view = this,

                    cbUpdateTrailing = function () {
                        view.collection.get( Math.round( this.trailingId ) ).select( { label: "trailing" } );
                    };

                // Animate the trailing element and make it catch up. Use the .select() method with the label
                // "trailing".
                $( { trailingId: trailing } ).animate(
                    { trailingId: model.id },
                    { step: cbUpdateTrailing, done: cbUpdateTrailing, duration: trailingLag }
                );
            }
745858
function(model, options) {
      this._byId[model.cid] = model;
      if (model.id != null) this._byId[model.id] = model;
      if (!model.collection) model.collection = this;
      model.on('all', this._onModelEvent, this);
    }
1116644
function(modelItem) {
			if(!modelItem){
				return null;
			}
			var modelId = this._model.getId(modelItem);
			if(this._dict[modelId]){
				this._dict[modelId].gridChildren = null;
			}
		}
1205887
@Override public void setModel(TableModel model)
   {
      super.setModel(model);
      int columns = model.getColumnCount();
      TableColumnModel tableColumnModel = getColumnModel();
      for (int index = 0; index < columns; index++)
      {
         tableColumnModel.getColumn(index).setPreferredWidth(m_columnWidth);
      }
   }
490235
function (model, options) {
        this._index(model);
        if (!model.collection) model.collection = this;
        if (model.on) model.on('all', this._onModelEvent, this);
    }
726142
public final void setModel(PixelModel newModel) {
		if (newModel == null) throw new NullPointerException();
		
		if (model != newModel) {
			if (model != null)
				model.removeChangeListener(modelListener);
			model = newModel;
			model.addChangeListener(modelListener);
			update();
		}
	}
779150
def setModel(self, model):
        

        LOGGER.debug("> Setting '{0}' model.".format(model))

        if not model:
            return

        umbra.ui.views.Abstract_QTreeView.setModel(self, model)
1248784
def setModel(self, model, relayout=True):
        """"""
        self._model = model
        sel_model = self.dataTable.selectionModel()
        sel_model.currentColumnChanged.connect(
                self._resizeCurrentColumnToContents)

        # Asociate the models (level, vertical index and horizontal header)
        # with its corresponding view.
        self._reset_model(self.table_level, DataFrameLevelModel(model,
                                                                self.palette(),
                                                                self.font()))
        self._reset_model(self.table_header, DataFrameHeaderModel(
                                                            model,
                                                            0,
                                                            self.palette()))
        self._reset_model(self.table_index, DataFrameHeaderModel(
                                                            model,
                                                            1,
                                                            self.palette()))

        # Needs to be called after setting all table models
        if relayout:
            self._update_layout()
790530
def setModel(self, model):
        
        super(StimulusView, self).setModel(model)
        self.setSelectionModel(ComponentSelectionModel(model))
        # initialize nested list to appropriate size
        self._rects = [[None] * self.model().columnCountForRow(x) for x in range(self.model().rowCount())]

        self._viewIsDirty = True
        self._calculateRects()
947206
function (model) {

                var ret = [];

                function getSubModel(obj) {

                    if (obj === model) {
                        return;
                    }

                    if (_.indexOf(ret, obj) !== -1) {
                        // already in list
                        return;
                    }

                    if (obj instanceof Model) {
                        ret.push(obj);
                        return;
                    }

                    for (var key in obj) {
                        if (obj.hasOwnProperty(key)) {
                            var value = obj[key];

                            if (value instanceof Array) {
                                for (var i = 0; i < value.length; i++) {
                                    getSubModel(value[i]);
                                }
                            } else if (value instanceof List) {
                                value.each(getSubModel);
                            } else if (value instanceof Object) {
                                getSubModel(value);
                            }
                        }
                    }
                }

                getSubModel(model.$);

                return ret;

            }
930637
function publicModel(model, readyPromise) {
    var res = [];

    function find(filter) {
        var mergedFilter = _.merge({}, model.filter, filter);
        var filteredModel = getModel(model.io, model.name, model.itemDef, model.modelDef, mergedFilter);
        if (model.children.indexOf(filteredModel) === -1) model.children.push(filteredModel);

        return filteredModel;
    }


    function getByIds(ids) {
        var items = [];
        for (var i = 0; i < res.length; i++) {
            if (ids.indexOf(res[i].id) !== -1) items.push(res[i]);
        }
        return items;
    }

    utils.defineProperties(res, {
        _isModel: { value: true },
        name: { value: model.name },

        ready: { value: readyPromise },

        create: { value: function(props) {
            props = props || {};

            var item = modelItem(props, model);
            item.ready = item.update(props).then(function() {
                model._addItem(item);
            });
            return item;
        } },

        itemById: { value: function(id) {
            for (var i = 0; i < this.length; i++) {
                if (this[i].id === id) return this[i];
            }
            return false;
        } },

        find: { value: find },
        filter: { value: find },

        findOne: { value: function(filter) {
            return find(filter).then(function(val) {
                if (val.length) return val[0];
                return false;
            });
        } },

        refresh: { value: function() {
            return Promise.all(_.map(this, function(item) {
                return item.refresh();
            }));
        } },

        then: { value: function() {
            return readyPromise.then.apply(readyPromise, arguments);
        } },

        catch: { value: function() {
            return readyPromise.catch.apply(readyPromise, arguments);
        } },

        /**
         * Override array modification properties
         */

        _pop: { value: arrayPop },

        pop: { value: function() {
            var lastItem = arrayPop.call(this);
            lastItem.delete();
            return lastItem;
        } },

        _push: { value: arrayPush },

        push: { value: function() {
            for (var i = 0; i < arguments.length; i++) {
                this.create(arguments[i]);
            }
            return this.length;
        } },

        _shift: { value: arrayShift },

        shift: { value: function() {
            var firstItem = arrayShift.call(this);
            firstItem.delete();
            return firstItem;
        } },

        _splice: { value: arraySplice },

        splice: { value: function(start, deleteCount) {
            var items = _.map(arraySlice.call(arguments, 2), function(itm) {
                var item = modelItem(itm, model);
                item.ready = item.update(itm);
                return item;
            });

            items.unshift(start, deleteCount);

            var removed = arraySplice.apply(this, items);
            for (var i = 0; i < removed.length; i++) removed.delete();
            return removed;
        } },

        _unshift: { value: arrayUnshift },

        unshift: { value: function() {
            return arrayUnshift.apply(this, _.map(arguments, function(itm) {
                var item = modelItem(itm, model);
                item.ready = item.update(itm);
                return item;
            }));
        } },

        __connection: { value: model.name }
    });

    //Object.defineProperties(res, );

    _.merge(res, utils.createCalculateProperty(function(previous, flags) {
        if (!previous) return;

        var isArray = _.isArray(previous), prevId;
        if (isArray) {
            prevId = _.map(previous, function(val) {
                if (_.isNumber(val)) return val;
                return val.id;
            });
        } else prevId = [_.isNumber(previous) ? previous : previous.id];

        return readyPromise.then(function() {
            var itms = getByIds(prevId);

            function getItems() {
                if (isArray) return { _stWrapped: true, val: itms};

                return { _stWrapped: true, val: itms.length ? itms[0] : null };
            }

            if (!flags.noRefresh) {
                return Promise.all(_.map(itms, function(item) {
                    return item.refresh();
                })).then(getItems);
            }

            return getItems();
        });
    }.bind(this)));

    return res;
}
818539
function(model) {
    if (model.isNew())
      return false
    this.localStorage().removeItem(this.name+"-"+model.id);
    this.records = _.reject(this.records, function(id){
      return id === model.id.toString();
    });
    this.save();
    return model;
  }
361438
function(model, options) {
            options || (options = {});
            if (!(model instanceof Model)) {
                var attrs = model;
                options.collection = this;
                model = new this.model(options, attrs);
            } else if (!model.collection) {
                model.collection = this;
            }
            return model;
        }
48009
function(model, options) {
      model = this._prepareModel(model, options);
      this.add(model, _.extend({at: 0}, options));
      return model;
    }
1176170
function(model, options) {
      options = options ? _.clone(options) : {};
      var wait = options.wait;
      model = this._prepareModel(model, options);
      if (!model) return false;
      if (!wait) this.add(model, options);
      var collection = this;
      var success = options.success;
      options.success = function(m, resp, callbackOpts) {
        if (wait) collection.add(m, callbackOpts);
        if (success) success.call(callbackOpts.context, m, resp, callbackOpts);
      };
      model.save(null, options);
      return model;
    }