Class: S3Relay::Upload

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/s3_relay/upload.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.importedObject



19
20
21
# File 'app/models/s3_relay/upload.rb', line 19

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

.pendingObject



15
16
17
# File 'app/models/s3_relay/upload.rb', line 15

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

Instance Method Details

#imported?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/models/s3_relay/upload.rb', line 27

def imported?
  state == "imported"
end

#mark_imported!Object



31
32
33
# File 'app/models/s3_relay/upload.rb', line 31

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

#notify_parentObject



35
36
37
38
39
40
41
# File 'app/models/s3_relay/upload.rb', line 35

def notify_parent
  return unless parent.present?

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

#pending?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/s3_relay/upload.rb', line 23

def pending?
  state == "pending"
end

#private_urlObject



43
44
45
# File 'app/models/s3_relay/upload.rb', line 43

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