Module: ActiveFedora::File::Attributes
- Included in:
- ActiveFedora::File
- Defined in:
- lib/active_fedora/file/attributes.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #digest ⇒ Object
- #dirty_size ⇒ Object
- #empty? ⇒ Boolean
- #has_content? ⇒ Boolean
- #original_name ⇒ Object
- #original_name=(name) ⇒ Object
- #persisted_size ⇒ Object
- #size ⇒ Object
Instance Attribute Details
#mime_type ⇒ Object
5 6 7 |
# File 'lib/active_fedora/file/attributes.rb', line 5 def mime_type @mime_type ||= fetch_mime_type end |
Instance Method Details
#digest ⇒ Object
17 18 19 20 |
# File 'lib/active_fedora/file/attributes.rb', line 17 def digest response = .ldp_source.graph.query(predicate: ActiveFedora::RDF::Fcrepo4.digest) response.map(&:object) end |
#dirty_size ⇒ Object
26 27 28 |
# File 'lib/active_fedora/file/attributes.rb', line 26 def dirty_size content.size if changed? && content.respond_to?(:size) end |
#empty? ⇒ Boolean
38 39 40 |
# File 'lib/active_fedora/file/attributes.rb', line 38 def empty? !has_content? end |
#has_content? ⇒ Boolean
34 35 36 |
# File 'lib/active_fedora/file/attributes.rb', line 34 def has_content? size && size > 0 end |
#original_name ⇒ Object
9 10 11 |
# File 'lib/active_fedora/file/attributes.rb', line 9 def original_name @original_name ||= fetch_original_name end |
#original_name=(name) ⇒ Object
13 14 15 |
# File 'lib/active_fedora/file/attributes.rb', line 13 def original_name= name @original_name = name end |
#persisted_size ⇒ Object
22 23 24 |
# File 'lib/active_fedora/file/attributes.rb', line 22 def persisted_size ldp_source.head.headers['Content-Length'].to_i unless new_record? end |
#size ⇒ Object
30 31 32 |
# File 'lib/active_fedora/file/attributes.rb', line 30 def size dirty_size || persisted_size end |