Module: Pageflow::HostedFile

Extended by:
ActiveSupport::Concern
Includes:
UploadedFile
Included in:
AudioFile, VideoFile
Defined in:
app/models/concerns/pageflow/hosted_file.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UploadedFile

#usage_id

Class Method Details

.columns(t) ⇒ Object


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/concerns/pageflow/hosted_file.rb', line 59

def self.columns(t)
  t.belongs_to(:entry, index: true)
  t.belongs_to(:uploader, index: true)

  t.string(:state)
  t.string(:rights)

  t.string(:attachment_on_filesystem_file_name)
  t.string(:attachment_on_filesystem_content_type)
  t.integer(:attachment_on_filesystem_file_size, limit: 8)
  t.datetime(:attachment_on_filesystem_updated_at)

  t.string(:attachment_on_s3_file_name)
  t.string(:attachment_on_s3_content_type)
  t.integer(:attachment_on_s3_file_size, limit: 8)
  t.datetime(:attachment_on_s3_updated_at)

  t.timestamps
end

Instance Method Details

#attachmentObject


37
38
39
# File 'app/models/concerns/pageflow/hosted_file.rb', line 37

def attachment
  attachment_on_s3.present? ? attachment_on_s3 : attachment_on_filesystem
end

#attachment=(value) ⇒ Object


41
42
43
# File 'app/models/concerns/pageflow/hosted_file.rb', line 41

def attachment=(value)
  self.attachment_on_filesystem = value
end

#keep_on_filesystem_after_upload_to_s3?Boolean

Returns:

  • (Boolean)

45
46
47
# File 'app/models/concerns/pageflow/hosted_file.rb', line 45

def keep_on_filesystem_after_upload_to_s3?
  false
end

#retryable?Boolean

Returns:

  • (Boolean)

49
50
51
# File 'app/models/concerns/pageflow/hosted_file.rb', line 49

def retryable?
  can_retry?
end

#urlObject


53
54
55
56
57
# File 'app/models/concerns/pageflow/hosted_file.rb', line 53

def url
  if attachment_on_s3.present?
    attachment.url
  end
end