CRUD method: PATCH


 @return [Object]

 @see Crapi::Client#patch Crapi::Client#patch
335988
def patch(path, headers: {}, query: {}, payload: {})
      @parent.patch("/#{@segment}/#{path}".gsub(%r{/+}, '/'),
                    heades: @default_headers.merge(headers), query: query, payload: payload)
    end
1103549
def patch(self, instance, errors):
        
        if errors:
            return self.errors(errors)
        return self.updated(instance)
355025
def update
      if @user.update_attributes(permitted_params.user.merge({:password_required => true}))
        redirect_to new_session_url, :notice => t(:signed_up_successfully)
      else
        render :action => 'edit'
      end
    end
726476
function applyPatches (versions) {
    versions = sortVersions(versions, 'ASC')

    let state = []
    // iterate patches to the final one => get previous commit state
    versions.forEach((v) => {
      v.changes.forEach((c) => {
        if (c.operation === 'insert') {
          return state.push({
            entityId: c.entityId,
            entitySet: c.entitySet,
            entity: parse(c.serializedDoc),
            path: c.path
          })
        }

        if (c.operation === 'remove') {
          state = state.filter((e) => e.entityId !== c.entityId)
          return
        }

        const entityState = state.find((e) => e.entityId === c.entityId)
        applyPatch(entityState.entity, parse(c.serializedPatch), c.entitySet, documentModel)
      })
    })
    return state
  }
40471
def update(request)
      if options[:multiple]
        cats = request.every(options[:category])
        cats.each do |cat|
          if cat || options[:nils]
            @categories[cat] ||= 0
            @categories[cat] += 1
          end
        end

      else
        cat = @categorizer.call(request)
        if cat || options[:nils]
          @categories[cat] ||= 0
          @categories[cat] += 1
        end
      end
    end
502914
def patch(self, fields, **args):
        
        self_dict = dict([(key, value) for (key, value) in
                          self.to_dict().items()
                          if key in fields])
        if args:
            self_dict = dict(list(self_dict.items()) + list(args.items()))
        response = self.requester.patch(
            '/{endpoint}/{id}', endpoint=self.endpoint,
            id=self.id, payload=self_dict
        )
        obj_json = response.json()
        if 'version' in obj_json:
            self.__dict__['version'] = obj_json['version']
        return self
625385
def register(patch)
      q = @db[:tdp_patch].where(name: patch.name)
      if q.empty?
        @db[:tdp_patch].insert(
          name: patch.name,
          signature: patch.signature
        )
      else
        q.update(signature: patch.signature)
      end
    end
522114
def patch_refresh_from_db(model):
    
    if not hasattr(model, 'refresh_from_db'):
        return
    old_refresh_from_db = model.refresh_from_db

    def new_refresh_from_db(self, using=None, fields=None):
        if fields is not None:
            fields = append_translated(self.__class__, fields)
        return old_refresh_from_db(self, using, fields)
    model.refresh_from_db = new_refresh_from_db
338010
def update
			@instance = get_model.find(params[:id])

			respond_to do |format|
				if @instance.update(instance_params)
					flash[:notice] = "#{get_model.name} was successfully updated."
					format.html { render 'quick_dry/show' }
					format.json { render json:@instance, status: :ok, location: get_url}
				else
					format.html { render 'quick_dry/edit' }
					format.json { render json: @instance.errors, status: :unprocessable_entity}
				end
			end
		end
662647
private function modify()
    {
        $modify = $this->dsql()->del('where');
        $modify->where($this->getElement($this->id_field), $this->id);

        if (empty($this->dirty)) {
            return $this;
        }

        foreach ($this->dirty as $name => $junk) {
            if ($el = $this->hasElement($name)) {
                if ($el instanceof Field) {
                    $el->updateModifyQuery($modify);
                }
            }
        }

        // Performs the actual database changes. Throw exceptions if problem occurs
        $this->hook('beforeModify', array($modify));
        if ($modify->args['set']) {
            $modify->update();
        }

        if ($this->dirty[$this->id_field]) {
            $this->id = $this->get($this->id_field);
        }

        $this->hook('afterModify');

        if ($this->_save_as === false) {
            return $this->unload();
        }
        $id = $this->id;
        if ($this->_save_as) {
            $this->unload();
        }
        $o = $this->_save_as ?: $this;

        return $o->load($id);
    }
1248417
def patch(attrs, updates):
    """"""
    orig = {}
    for attr, value in updates:
        orig[attr] = attrs[attr]
        attrs[attr] = value
    return orig
28900
def update_with(&blk)
      self.class.options.each do |name, config|
        value = yield(config)
        @values[name] = value unless value.nil?
      end
    end
1031293
def patch(self, route: str(), callback: object()):
        
        self.__set_route('patch', {route: callback})
        return RouteMapping
779413
def update(class_or_classname, record_id, new_attrs)
      class_or_classname = find_or_materialize(class_or_classname)
      json_for_update = coerced_json(new_attrs, class_or_classname)
      http_patch("/services/data/v#{self.version}/sobjects/#{class_or_classname.sobject_name}/#{record_id}", json_for_update)
    end
310731
function patch(obj, method, optionsArgIndex) {
    var orig = obj[method];
    if (!orig) return;
    obj[method] = function () {
      var opts = arguments[optionsArgIndex];
      var file = null;
      if (opts) {
        file = typeof opts == 'string' ? opts : opts.filename;
      }
      if (file) callback(file);
      return orig.apply(this, arguments);
    };
  }
935526
public function save(
        $data,
        $id = null,
        $patch = false,
        $flush = true
    ) {
        /*
         * TODO: https://github.com/sulu-io/sulu/pull/1171
         * This method needs to be refactored since in the first
         * iteration the logic was just moved from the Controller to this class due
         * to better reusability.
         */

        if ($id) {
            /** @var Contact $contact */
            $contact = $this->contactRepository->findById($id);

            if (!$contact) {
                throw new EntityNotFoundException($this->contactRepository->getClassName(), $id);
            }
            if (!$patch || $this->getProperty($data, 'account')) {
                $this->setMainAccount($contact, $data);
            }
            if (!$patch || $this->getProperty($data, 'emails')) {
                $this->processEmails($contact, $this->getProperty($data, 'emails', []));
            }
            if (!$patch || $this->getProperty($data, 'phones')) {
                $this->processPhones($contact, $this->getProperty($data, 'phones', []));
            }
            if (!$patch || $this->getProperty($data, 'addresses')) {
                $this->processAddresses($contact, $this->getProperty($data, 'addresses', []));
            }
            if (!$patch || $this->getProperty($data, 'notes')) {
                $this->processNotes($contact, $this->getProperty($data, 'notes', []));
            }
            if (!$patch || $this->getProperty($data, 'faxes')) {
                $this->processFaxes($contact, $this->getProperty($data, 'faxes', []));
            }
            if (!$patch || $this->getProperty($data, 'socialMediaProfiles')) {
                $this->processSocialMediaProfiles($contact, $this->getProperty($data, 'socialMediaProfiles', []));
            }
            if (!$patch || $this->getProperty($data, 'tags')) {
                $this->processTags($contact, $this->getProperty($data, 'tags', []));
            }
            if (!$patch || $this->getProperty($data, 'urls')) {
                $this->processUrls($contact, $this->getProperty($data, 'urls', []));
            }
            if (!$patch || $this->getProperty($data, 'categories')) {
                $this->processCategories($contact, $this->getProperty($data, 'categories', []));
            }
            if (!$patch || $this->getProperty($data, 'bankAccounts')) {
                $this->processBankAccounts($contact, $this->getProperty($data, 'bankAccounts', []));
            }
        } else {
            $contact = $this->contactRepository->createNew();
        }

        if (!$patch || null !== $this->getProperty($data, 'firstName')) {
            $contact->setFirstName($this->getProperty($data, 'firstName'));
        }
        if (!$patch || null !== $this->getProperty($data, 'lastName')) {
            $contact->setLastName($this->getProperty($data, 'lastName'));
        }
        if (!$patch || null !== $this->getProperty($data, 'avatar')) {
            $this->setAvatar($contact, $this->getProperty($data, 'avatar'));
        }
        if (!$patch || null !== $this->getProperty($data, 'note')) {
            $contact->setNote($this->getProperty($data, 'note'));
        }
        if (!$patch || null !== $this->getProperty($data, 'medias')) {
            $this->setMedias($contact, $this->getProperty($data, 'medias', []));
        }

        if (!$patch || $this->getProperty($data, 'title')) {
            $this->setTitleOnContact($contact, $this->getProperty($data, 'title'));
        }

        if (!$patch || $this->getProperty($data, 'formOfAddress')) {
            $formOfAddress = $this->getProperty($data, 'formOfAddress');

            if (is_numeric($formOfAddress) || is_string($formOfAddress)) {
                $contact->setFormOfAddress($formOfAddress);
            }

            if (!is_null($formOfAddress) && is_array($formOfAddress) && array_key_exists('id', $formOfAddress)) {
                @trigger_error(
                    'Passing the "formOfAddress" as object is deprecated and will not be supported in Sulu 2.0',
                    E_USER_DEPRECATED
                );
                $contact->setFormOfAddress($formOfAddress['id']);
            }
        }

        if (!$patch || $this->getProperty($data, 'salutation')) {
            $contact->setSalutation($this->getProperty($data, 'salutation'));
        }

        if (!$patch || $this->getProperty($data, 'birthday')) {
            $birthday = $this->getProperty($data, 'birthday');
            if (!empty($birthday)) {
                $birthday = new DateTime($birthday);
            } else {
                $birthday = null;
            }
            $contact->setBirthday($birthday);
        }

        if (!$id) {
            $parentData = $this->getProperty($data, 'account');
            if (null != $parentData &&
                null != $parentData['id'] &&
                'null' != $parentData['id'] &&
                '' != $parentData['id']
            ) {
                /** @var AccountInterface $parent */
                $parent = $this->accountRepository->findAccountById($parentData['id']);
                if (!$parent) {
                    throw new EntityNotFoundException(
                        self::$accountContactEntityName,
                        $parentData['id']
                    );
                }

                // Set position on contact
                $position = $this->getPosition($this->getProperty($data, 'position'));

                // create new account-contact relation
                $this->createMainAccountContact(
                    $contact,
                    $parent,
                    $position
                );
            }
            // add urls, phones, emails, tags, bankAccounts, notes, addresses,..
            $this->addNewContactRelations($contact, $data);
            $this->processCategories($contact, $this->getProperty($data, 'categories', []));
        }

        $this->em->persist($contact);

        if ($flush) {
            $this->em->flush();
        }

        return $contact;
    }
732630
function patch(parent$, partialChange) {
  setImmediate(() => {
    if (
      partialChange === null ||
      typeof partialChange !== "object" ||
      typeof parent$.value !== "object"
    ) {
      parent$(partialChange);
    } else {
      parent$(Object.assign({}, parent$.value, partialChange));
    }
  });
  return parent$;
}