/*
Add a model to the list
@model : model to add
@options
760417
function(model, options) {
            var item, tag;

            // Define options
            options = _.defaults(options || {}, {
                silent: false,
                render: true,
                at: _.size(this.items),
            });

            if (this.items[model.id] != null) {
                this.removeModel(model);
            }

            item = new this.Item({
                "model": model,
                "list": this,
                "collection": this.collection
            }, this);
            this.listenTo(model, "set", function() {
                item.update();
                this.applyFilter(item);
            });
            this.listenTo(model, "id", function(newId, oldId) {
                this.items[newId] = this.items[oldId];
                delete this.items[oldId];
            });

            item.update();
            tag = this.Item.prototype.tagName;
            if (this.Item.prototype.className) tag = tag+"."+this.Item.prototype.className.split(" ")[0];

            if (options.at > 0) {
                this.$("> "+tag).eq(options.at-1).after(item.$el);
            } else {
                this.$el.prepend(item.$el);
            }
            this.items[model.id] = item;

            this.applyFilter(item);

            if (!options.silent) this.trigger("add", model);
            if (options.render) this.update();

            return this;
        }
1276501
function (model) {
            if (!this.ngModel) {
                return;
            }
            var index = this.selected.indexOf(model);
            if (index !== -1) {
                this.selected.splice(index, 1);
                if (this.multiple) {
                    this.ngModel.$setViewValue(this.selected);
                } else {
                    this.ngModel.$setViewValue(undefined);
                }
            }

        }
9030
function(model)
  {
    var exists = this.has( model.$key() );
    var matches = this.filter( model );

    if ( exists && !matches )
    {
      this.remove( model );
    }
    if ( !exists && matches )
    {
      this.add( model );
    }
  }
342817
public function append(Model $model)
    {
        $result = null;
        // If the list was filtered make sure that value is set on the model.
        if ($this->filter !== null) {
            $result = $this->filter->setFilterValuesOnModel($model);
        }
        $model->save();

        // Make sure the list is refetched.
        $this->invalidate();

        return ($result === null) ? $model : $result;
    }
521849
function(model, options) {
    options = options ? extend({}, options) : {};
    if (!(model = this._prepareModel(model, options))){
      return false;
    }
    if (!options.wait){
      this.add(model, options);
    }
    var collection = this;
    options.cb = options.callback;
    options.callback = function cb(err, model, response){
      if (err){
        return callback(err, model, response, options);
      }
      if (options.wait){
        collection.add(model, options);
      }
      callback(null, model, response, options);
    };

    model.save(null, options);
    return model;
  }
995119
def add(self, **args):
        
        kwargs = self.getKwargs(args)
        if kwargs:
            self.model.add(**kwargs)
824949
def expand_options(options={}, opts={}, model=nil)
      options = get_value_of options, model
      config_opts = {
        :not_expand => [],
        :not_call_symbol => []
      }.merge! opts
      if options.kind_of? Hash
        opts = {}
        options.each do |column, config|
          if not config_opts[:not_expand].include? column.to_sym
            if not config_opts[:not_call_symbol].include? config
              opts[column.to_sym] = expand_options(get_value_of(config, model), config_opts, model)
            else
              opts[column.to_sym] = expand_options(config, config_opts, model)
            end
          else
            opts[column.to_sym] = config
          end
        end
        return opts
      else
        return get_value_of options, model
      end
    end
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;

            }
1252650
def add(self, models):
        
        if models is None:
            return

        models = self._check_model_types(models)
        self._selected.update(models)
        self._selected = reduce_to_parent_states(self._selected)
931914
function addProperty (model, key, field_definition) {
	var property = {
		get : function() {
			return this['_' + key];
		},
		set : function(value) {
			this._updated_fields[key] = value;
			// should we track old values here and revert them on save error?
			this['_' + key] = value;
		}
	};

	if (field_definition.get) {
		property.get = field_definition.get;
	}

	if (field_definition.set) {
		property.set = function (value) {
			field_definition.set.call(this, value);
			this._updated_fields[key] = this['_' + key];
		};
	}			

	Object.defineProperty(model.prototype, key, property);
}
104971
function(model, options) {
      options = options ? _.extend({}, options) : {};
      if (!(model = this._prepareModel(model, options))) return false;
      if (!options.wait) this.add(model, options);
      var collection = this;
      var success = options.success;
      options.success = function(model, resp) {
        if (options.wait) collection.add(model, options);
        if (success) success(model, resp, options);
      };

      var savePromise = model.save(null, options);
      if (savePromise) {
        savePromise.catch(function(err) {});
      }
      return model;
    }
610769
function (model, options) {
        if (this === model.collection) delete model.collection;
        this._deIndex(model);
        if (model.off) model.off('all', this._onModelEvent, this);
    }
786002
def add_option(name, parameters)
      self.class.handle_warnings(name, **parameters.dup)
      chain_options.merge(name => parameters.merge(method_hash(parameters)))
    end
557555
function(model, at){
        model = new this._Model(model, this.options.Model.options);

        if (!this.hasModel(model)) {
            // Attach events to the model that will signal collection events
            this.attachModelEvents(model);

            // If _models is empty, then we make sure to push instead of splice.
            at = this.length == 0 ? void 0 : at;

            if (at != void 0) {
                this._models.splice(at, 0, model);
            } else {
                this._models.push(model);
            }

            this.length = this._models.length;

            this._changed = true;

            // if at is undefined, then it would be at the end of the array, thus this.length-1
            this.signalAdd(model, at != void 0 ? at : this.length - 1);
        }

        return this;
    }
1175822
def add_model(self, ic, N=1, index=0):
        
        if type(index) in [list,tuple]:
            if len(index) != N:
                raise ValueError('If a list, index must be of length N.')
        else:
            index = [index]*N

        for idx in index:
            existing = self.get_system(idx)
            tag = len(existing)
            self.add_child(ModelNode(ic, index=idx, tag=tag))
931586
def add_model(self, model_type: str, model_uuid: str, meta: dict,
                  template_model: Template, update_default: bool=False):
        """"""
        if update_default or model_type not in self.meta:
            self.meta[model_type] = meta["default"]
        model_meta = meta["model"]
        self.models.setdefault(model_type, {})[model_uuid] = model_meta
        model_directory = os.path.join(self.cached_repo, model_type)
        os.makedirs(model_directory, exist_ok=True)
        model = os.path.join(model_directory, model_uuid + ".md")
        if os.path.exists(model):
            os.remove(model)
        links = {}
        for m_type, items in self.models.items():
            for uuid in items:
                if uuid in model_meta["dependencies"]:
                    links[uuid] = os.path.join("/", m_type, "%s.md" % uuid)
        with open(model, "w") as fout:
            fout.write(template_model.render(model_type=model_type, model_uuid=model_uuid,
                                             meta=model_meta, links=links))
        git.add(self.cached_repo, [model])
        self._log.info("Added %s", model)
762246
def add_input_option(option_name, *args)
      (@input_options ||= []).push(option_name)
      args.each { |ea| @input_options.push(Shellwords.escape(ea.to_s)) }

      # Support call chaining:
      self
    end