Class: S3Relay::Upload

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
app/models/s3_relay/upload.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.importedObject



33
34
35
# File 'app/models/s3_relay/upload.rb', line 33

def self.imported
  where(state: "imported")
end

.pendingObject



29
30
31
# File 'app/models/s3_relay/upload.rb', line 29

def self.pending
  where(state: "pending")
end

Instance Method Details

#imported?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/models/s3_relay/upload.rb', line 41

def imported?
  state == "imported"
end

#mark_imported!Object



45
46
47
# File 'app/models/s3_relay/upload.rb', line 45

def mark_imported!
  update_attributes(state: "imported", imported_at: Time.now)
end

#notify_parentObject



49
50
51
52
53
54
55
# File 'app/models/s3_relay/upload.rb', line 49

def notify_parent
  return unless parent.present?

  if parent.respond_to?(:import_upload)
    parent.import_upload(id)
  end
end

#pending?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/models/s3_relay/upload.rb', line 37

def pending?
  state == "pending"
end

#private_urlObject



61
62
63
# File 'app/models/s3_relay/upload.rb', line 61

def private_url
  S3Relay::PrivateUrl.new(uuid, filename).generate
end

#public_urlObject



57
58
59
# File 'app/models/s3_relay/upload.rb', line 57

def public_url
  S3Relay::PrivateUrl.new(uuid, filename).public_url
end