app/services/mutation_operations/attachments/attribute.rb
# Assign attachment values to a given model and mutably
# alter the provided `args`, so that they can later be used
#
# @note `args` is mutated by this method, as it deletes keys
#   that are consumed by attachments.
# @param [ApplicationRecord] model
# @param [{ Symbol => Object }] args
# @return [void]
Assign attachment values to a given model and mutably
alter the provided `args`, so that they can later be used
Assign attachment values to a given model and mutably alter the provided ` args ` so that they can later be used
def assign!(model, args)
        attacher = attacher_for model
        file = args.delete name
        should_clear = args.delete clear
        new_metadata = prepare_metadata args.delete metadata
        if file.present?
          attacher.model_assign file
          attacher.add_metadata new_metadata if new_metadata.present?
        elsif should_clear
          attacher.assign nil
        elsif new_metadata.present?
          attacher.add_metadata new_metadata
        end
      end
def assign! ( model , args ) attacher = attacher_for model file = args . delete name should_clear = args . delete clear new_metadata = prepare_metadata args . delete metadata if file . present? attacher . model_assign file attacher . add_metadata new_metadata if new_metadata . present? elsif should_clear attacher . assign nil elsif new_metadata . present? attacher . add_metadata new_metadata end end
Assign attachment values to a given model and mutably
alter the provided `args`, so that they can later be used
Assign attachment values to a given model and mutably alter the provided ` args ` so that they can later be used
# Replace file and maybe update metadata # Clear the file, ignore metadata # Update metadata only
None
void
model
args
None
note
`args` is mutated by this method, as it deletes keys that are consumed by attachments.
` args ` is mutated by this method as it deletes keys that are consumed by attachments .