module BgS3uploadable::Uploadable

Private Instance Methods

queue_s3key_notifications() click to toggle source
# File lib/bg_s3uploadable/uploadable.rb, line 25
def queue_s3key_notifications
  return if @s3key_notifications_required.blank?

  @s3key_notifications_required.each do |attachment|
    UploaderJob.perform_later self, attachment.to_s
  end

  @s3key_notifications_required = nil
end
set_s3key(attachment, key) click to toggle source
# File lib/bg_s3uploadable/uploadable.rb, line 11
def set_s3key(attachment, key)
  return if key.blank?

  fail ArgumentError, 'Invalid key' unless key =~ /\Auploads\//

  write_attribute :"#{attachment}_s3key", key

  @s3key_notifications_required ||= []
  @s3key_notifications_required << attachment

  # Clear the old attachment out while processing.
  send(:"#{attachment}=", nil)
end