module PaperclipLambda::Attachment::InstanceMethods

Public Instance Methods

process_update_in_lambda(options = {}) click to toggle source
# File lib/paperclip_lambda/attachment.rb, line 26
def process_update_in_lambda(options = {})
  lambda_definitions = instance.class.paperclip_definitions[name][:lambda]
  attributes_hash = { }

  lambda_definitions[:attributes].each do |attribute|
    attributes_hash[attribute] = instance.send(attribute)
  end

  payload = {
    path: path,
    old_path: options[:old_path],
    bucket: instance.send(name).options[:bucket],
    attributes: attributes_hash
  }

  PaperclipLambda::Client.new(lambda_definitions[:function_name], payload)

  if instance.respond_to?(:"#{name}_processing?")
    instance.send("#{name}_processing=", false)
    instance.class.where(instance.class.primary_key => instance.id).update_all({ "#{name}_processing" => false })
  end
end
queue_all_for_delete_with_lambda() click to toggle source
# File lib/paperclip_lambda/attachment.rb, line 49
def queue_all_for_delete_with_lambda
  instance.prepare_enqueueing_for_deletion(name)
  queue_all_for_delete_without_lambda
end
save_with_lambda() click to toggle source
# File lib/paperclip_lambda/attachment.rb, line 16
def save_with_lambda
  was_dirty = @dirty

  save_without_lambda.tap do
    if was_dirty
      instance.prepare_enqueueing_for(name)
    end
  end
end