Module: Pageflow::UploadableFile

Extended by:
ActiveSupport::Concern
Includes:
ReusableFile
Included in:
AudioFile, ImageFile, TextTrackFile, VideoFile
Defined in:
app/models/concerns/pageflow/uploadable_file.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from ReusableFile

#cache_key, #file_name, #file_type, #nested_files, #original_url, #parent_allows_type_for_nesting, #parent_belongs_to_same_entry, #retry!

Instance Method Details

#attachmentObject



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

def attachment
  attachment_on_s3
end

#attachment=(value) ⇒ Object



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

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

#attachment_default_urlObject

Overwritten if a file type wants to merge its attachments default_url into Pageflow.config.paperclip_s3_default_options. (See Pageflow::ImageFile for example)



56
57
58
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 56

def attachment_default_url
  ''
end

#attachment_styles(_attachment) ⇒ Object

Overwritten if a file type wants to add additional styles to Pageflow.config.paperclip_s3_default_options. (See Pageflow::ImageFile for example)



63
64
65
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 63

def attachment_styles(_attachment)
  {}
end

#attachments_for_exportObject

ReusableFile-overrides:



69
70
71
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 69

def attachments_for_export
  [attachment]
end

#basenameObject



79
80
81
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 79

def basename
  File.basename(attachment.original_filename, '.*')
end

#can_upload?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 83

def can_upload?
  uploading?
end

#direct_upload_configObject



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

def direct_upload_config
  Pageflow.config.paperclip_direct_upload_options.call(attachment)
end

#failed?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 95

def failed?
  uploading_failed?
end

#publish!Object



99
100
101
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 99

def publish!
  file_uploaded!
end

#ready?Boolean

Returns:

  • (Boolean)


91
92
93
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 91

def ready?
  attachment.present?
end

#retryable?Boolean

Returns:

  • (Boolean)


87
88
89
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 87

def retryable?
  false
end

#urlObject



73
74
75
76
77
# File 'app/models/concerns/pageflow/uploadable_file.rb', line 73

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