Module: Ddr::Models::HasContent
- Extended by:
- ActiveSupport::Concern, Deprecation
- Included in:
- Attachment, Component, Target
- Defined in:
- lib/ddr/models/has_content.rb
Instance Method Summary collapse
- #content_changed? ⇒ Boolean
- #content_human_size ⇒ Object
- #content_major_type ⇒ Object
- #content_size ⇒ Object
- #content_sub_type ⇒ Object
- #content_type ⇒ Object
- #content_type=(mime_type) ⇒ Object
- #derivatives ⇒ Object
- #has_extracted_text? ⇒ Boolean
- #image? ⇒ Boolean
- #last_virus_check ⇒ Object
- #last_virus_check_on ⇒ Object
- #last_virus_check_outcome ⇒ Object
- #original_filename ⇒ Object
- #original_filename=(filename) ⇒ Object
- #pdf? ⇒ Boolean
- #techmd ⇒ Object
-
#upload(file, opts = {}) ⇒ Object
Convenience method wrapping FileManagement#add_file.
-
#upload!(file, opts = {}) ⇒ Object
Set content to file and save.
- #virus_checks ⇒ Object
- #with_content_file(&block) ⇒ Object
Instance Method Details
#content_changed? ⇒ Boolean
102 103 104 |
# File 'lib/ddr/models/has_content.rb', line 102 def content_changed? content.content_changed? end |
#content_human_size ⇒ Object
58 59 60 |
# File 'lib/ddr/models/has_content.rb', line 58 def content_human_size ActiveSupport::NumberHelper.number_to_human_size(content_size) if content_size end |
#content_major_type ⇒ Object
66 67 68 |
# File 'lib/ddr/models/has_content.rb', line 66 def content_major_type content_type.split("/").first end |
#content_size ⇒ Object
54 55 56 |
# File 'lib/ddr/models/has_content.rb', line 54 def content_size content.size end |
#content_sub_type ⇒ Object
70 71 72 |
# File 'lib/ddr/models/has_content.rb', line 70 def content_sub_type content_type.split("/").last end |
#content_type ⇒ Object
62 63 64 |
# File 'lib/ddr/models/has_content.rb', line 62 def content_type content.mime_type end |
#content_type=(mime_type) ⇒ Object
74 75 76 |
# File 'lib/ddr/models/has_content.rb', line 74 def content_type= mime_type self.content.mimeType = mime_type end |
#derivatives ⇒ Object
46 47 48 |
# File 'lib/ddr/models/has_content.rb', line 46 def derivatives @derivatives ||= Ddr::Managers::DerivativesManager.new(self) end |
#has_extracted_text? ⇒ Boolean
106 107 108 |
# File 'lib/ddr/models/has_content.rb', line 106 def has_extracted_text? !extractedText.empty? end |
#image? ⇒ Boolean
78 79 80 |
# File 'lib/ddr/models/has_content.rb', line 78 def image? content_major_type == "image" end |
#last_virus_check ⇒ Object
90 91 92 |
# File 'lib/ddr/models/has_content.rb', line 90 def last_virus_check virus_checks.last end |
#last_virus_check_on ⇒ Object
94 95 96 |
# File 'lib/ddr/models/has_content.rb', line 94 def last_virus_check_on last_virus_check && last_virus_check.event_date_time end |
#last_virus_check_outcome ⇒ Object
98 99 100 |
# File 'lib/ddr/models/has_content.rb', line 98 def last_virus_check_outcome last_virus_check && last_virus_check.outcome end |
#original_filename ⇒ Object
38 39 40 |
# File 'lib/ddr/models/has_content.rb', line 38 def original_filename content.original_name end |
#original_filename=(filename) ⇒ Object
42 43 44 |
# File 'lib/ddr/models/has_content.rb', line 42 def original_filename=(filename) content.original_name = filename end |
#pdf? ⇒ Boolean
82 83 84 |
# File 'lib/ddr/models/has_content.rb', line 82 def pdf? content_type == "application/pdf" end |
#techmd ⇒ Object
50 51 52 |
# File 'lib/ddr/models/has_content.rb', line 50 def techmd @techmd ||= Ddr::Managers::TechnicalMetadataManager.new(self) end |
#upload(file, opts = {}) ⇒ Object
Convenience method wrapping FileManagement#add_file
28 29 30 |
# File 'lib/ddr/models/has_content.rb', line 28 def upload(file, opts={}) add_file(file, opts.merge(path: Ddr::Models::File::CONTENT)) end |
#upload!(file, opts = {}) ⇒ Object
Set content to file and save
33 34 35 36 |
# File 'lib/ddr/models/has_content.rb', line 33 def upload!(file, opts={}) upload(file, opts) save end |
#virus_checks ⇒ Object
86 87 88 |
# File 'lib/ddr/models/has_content.rb', line 86 def virus_checks Ddr::Events::VirusCheckEvent.for_object(self) end |
#with_content_file(&block) ⇒ Object
110 111 112 |
# File 'lib/ddr/models/has_content.rb', line 110 def with_content_file(&block) WithContentFile.new(self, &block) end |