Patch the current :class:`InstanceResource`
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
163373
public static void patch(HttpConsumer<HttpExchange> endpoint, MediaTypes... mediaTypes) {
        addResource(Methods.PATCH, HandlerUtil.BASE_PATH, endpoint, mediaTypes);
    }
1128267
function _updateSingleton() {
    if (!options.singletons) {
      return;
    }
    if (process.rebusinstances[folder]) {
      // Somebody added instance already.
      return;
    }
    // Save this instance to return the same for the same folder.
    process.rebusinstances[folder] = instance;
  }
902688
def update_on_instance_created(clazz, on_instance_created)
      return unless on_instance_created
      clazz.instance_eval do
        def instance_hooks
          hooks = (self.ancestors + [self]).map do |target|
            target.instance_variable_get(:@instance_hooks)
          end

          hooks.flatten!
          hooks.compact!
          hooks.uniq!
          hooks
        end

        @instance_hooks ||= []
        @instance_hooks << on_instance_created
      end
    end
610190
def patch_object(obj, attr, value):
    
    orig = getattr(obj, attr, no_value)

    try:
        setattr(obj, attr, value)

        yield obj
    finally:
        try:
            if orig is no_value:
                delattr(obj, attr)
            else:
                setattr(obj, attr, orig)
        except:
            pass
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);
    };
  }
893178
def _inject_patched_examples(self, existing_item, patched_item):
        """"""
        for key, _ in patched_item.examples.items():
            patched_example = patched_item.examples[key]
            existing_examples = existing_item.examples
            if key in existing_examples:
                existing_examples[key].fields.update(patched_example.fields)
            else:
                error_msg = 'Example defined in patch {} must correspond to a pre-existing example.'
                raise InvalidSpec(error_msg.format(
                    quote(patched_item.name)), patched_example.lineno, patched_example.path)
539609
def update_instance(self, name, settings):
        
        if name not in self.insts:
            raise ValueError("There's no instance named %s" % name)
        if 'module' in settings:
            raise ValueError(("Can't change module of existing instan"
                              + "ce %s") % name)
        self.l.info('update instance %-15s' % (name))
        for k, v in six.iteritems(settings):
            self.change_setting(name, k, v)
694120
def monkey_patch_override_instance_method(instance):
    
    def perform_override(override_fn):
        fn_name = override_fn.__name__
        original_fn_name = '_original_' + fn_name
        # Override instance method, if it hasn't already been done
        if not hasattr(instance, original_fn_name):
            original_fn = getattr(instance, fn_name)
            setattr(instance, original_fn_name, original_fn)
            bound_override_fn = override_fn.__get__(instance)
            setattr(instance, fn_name, bound_override_fn)
    return perform_override
866671
void updateInstance(T instance) {
        T oldInstance = this.instance.getAndSet(Preconditions.checkNotNull(instance, "instance"));
        if (oldInstance != null && oldInstance != instance) {
            oldInstance.close();
        }
    }
1248417
def patch(attrs, updates):
    """"""
    orig = {}
    for attr, value in updates:
        orig[attr] = attrs[attr]
        attrs[attr] = value
    return orig
252978
def fixup_instance(sender, **kwargs):
    
    instance = kwargs['instance']
    for model_field in instance._meta.fields:

        if not isinstance(model_field, JSONAttributeField):
            continue

        if hasattr(instance, '_attr_field'):
            raise FieldError('multiple JSONAttributeField fields: '
                             'only one is allowed per model!')

        field_name = model_field.name
        attrs = getattr(instance, field_name)

        # ensure JSONAttributeField's data is of JSONAttributes type
        if not isinstance(attrs, JSONAttributes):
            setattr(instance, field_name, JSONAttributes(attrs))
            attrs = getattr(instance, field_name)

        # Cache model instance on JSONAttributes instance and vice-versa
        attrs._instance = instance
        attrs._get_from_instance = functools.partial(
            getattr, instance, field_name)
        instance._attr_field = attrs

    if not hasattr(instance, '_attr_field'):
        raise FieldError('missing JSONAttributeField field in '
                         'fixup_instance decorator')
656763
def instance(self, *args, **kwargs):
        
        mod, cls = self.get_module_class()
        inst = cls(*args, **kwargs)
        logger.debug(f'inst: {inst}')
        return inst
859370
def _patch_original_class(self):
        
        cls = self._cls
        base_names = self._base_names

        # Clean class of attribute definitions (`attr.ib()`s).
        if self._delete_attribs:
            for name in self._attr_names:
                if (
                    name not in base_names
                    and getattr(cls, name, None) is not None
                ):
                    try:
                        delattr(cls, name)
                    except AttributeError:
                        # This can happen if a base class defines a class
                        # variable and we want to set an attribute with the
                        # same name by using only a type annotation.
                        pass

        # Attach our dunder methods.
        for name, value in self._cls_dict.items():
            setattr(cls, name, value)

        # Attach __setstate__. This is necessary to clear the hash code
        # cache on deserialization. See issue
        # https://github.com/python-attrs/attrs/issues/482 .
        # Note that this code only handles setstate for dict classes.
        # For slotted classes, see similar code in _create_slots_class .
        if self._cache_hash:
            existing_set_state_method = getattr(cls, "__setstate__", None)
            if existing_set_state_method:
                raise NotImplementedError(
                    "Currently you cannot use hash caching if "
                    "you specify your own __setstate__ method."
                    "See https://github.com/python-attrs/attrs/issues/494 ."
                )

            def cache_hash_set_state(chss_self, _):
                # clear hash code cache
                setattr(chss_self, _hash_cache_field, None)

            setattr(cls, "__setstate__", cache_hash_set_state)

        return cls
674507
def updated(self, instance):
        
        self.session_manager.save(instance, commit=True)
        return instance
576864
def register(cls, instance_class, name=None):
        
        if name is None:
            name = instance_class.__name__
        cls.INSTANCE_CLASSES[name] = instance_class
92143
def _monkey_patch_old_chef!
      require 'chef/event_dispatch/dispatcher'
      instance = self
      orig_method = Chef::EventDispatch::Dispatcher.instance_method(:library_file_loaded)
      Chef::EventDispatch::Dispatcher.send(:define_method, :library_file_loaded) do |filename|
        instance.events = self
        instance.monkey_patched = false
        @subscribers |= [instance]
        Chef::EventDispatch::Dispatcher.send(:define_method, :library_file_loaded, orig_method)
        orig_method.bind(self).call(filename)
      end
    end