Module: ActiveFedora::File::Attributes
- Included in:
- ActiveFedora::File
- Defined in:
- lib/active_fedora/file/attributes.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #create_date ⇒ Object
- #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
4 5 6 |
# File 'lib/active_fedora/file/attributes.rb', line 4 def mime_type @mime_type ||= fetch_mime_type end |
Instance Method Details
#create_date ⇒ Object
43 44 45 46 |
# File 'lib/active_fedora/file/attributes.rb', line 43 def create_date created = .attributes["http://fedora.info/definitions/v4/repository#created"] created && created.first end |
#digest ⇒ Object
16 17 18 19 20 21 |
# File 'lib/active_fedora/file/attributes.rb', line 16 def digest response = .ldp_source.graph.query(predicate: RDF::Vocab::PREMIS.hasMessageDigest) # fallback on old predicate for checksum response = .ldp_source.graph.query(predicate: fallback_digest_predicate) if response.empty? response.map(&:object) end |
#dirty_size ⇒ Object
27 28 29 |
# File 'lib/active_fedora/file/attributes.rb', line 27 def dirty_size content.size if changed? && content.respond_to?(:size) end |
#empty? ⇒ Boolean
39 40 41 |
# File 'lib/active_fedora/file/attributes.rb', line 39 def empty? !has_content? end |
#has_content? ⇒ Boolean
35 36 37 |
# File 'lib/active_fedora/file/attributes.rb', line 35 def has_content? size && size > 0 end |
#original_name ⇒ Object
8 9 10 |
# File 'lib/active_fedora/file/attributes.rb', line 8 def original_name @original_name ||= fetch_original_name end |
#original_name=(name) ⇒ Object
12 13 14 |
# File 'lib/active_fedora/file/attributes.rb', line 12 def original_name=(name) @original_name = name end |
#persisted_size ⇒ Object
23 24 25 |
# File 'lib/active_fedora/file/attributes.rb', line 23 def persisted_size ldp_source.head.content_length unless new_record? end |
#size ⇒ Object
31 32 33 |
# File 'lib/active_fedora/file/attributes.rb', line 31 def size dirty_size || persisted_size end |