module ActiveFedora::File::Attributes
Public Instance Methods
assign_attributes(_)
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 4 def assign_attributes(_) # nop end
create_date()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 47 def create_date created = metadata.attributes["http://fedora.info/definitions/v4/repository#created"] created&.first end
digest()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 20 def digest response = metadata.ldp_source.graph.query({ predicate: RDF::Vocab::PREMIS.hasMessageDigest }) # fallback on old predicate for checksum response = metadata.ldp_source.graph.query({ predicate: fallback_digest_predicate }) if response.empty? response.map(&:object) end
dirty_size()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 31 def dirty_size content.size if content_changed? && content.respond_to?(:size) end
empty?()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 43 def empty? !has_content? end
has_content?()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 39 def has_content? size&.positive? end
mime_type()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 8 def mime_type fetch_mime_type end
modified_date()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 52 def modified_date modified = metadata.attributes["http://fedora.info/definitions/v4/repository#lastModified"] modified&.first end
original_name()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 12 def original_name @original_name ||= fetch_original_name end
original_name=(name)
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 16 def original_name=(name) @original_name = name end
persisted_size()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 27 def persisted_size ldp_source.head.content_length unless new_record? end
size()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 35 def size dirty_size || persisted_size end
Private Instance Methods
default_mime_type()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 75 def default_mime_type 'text/plain' end
fallback_digest_predicate()
click to toggle source
Fcrepo4.digest was used by Fedora
< 4.3, but it was removed from the 2015-07-24 version of the fedora 4 ontology fedora.info/definitions/v4/2015/07/24/repository and from rdf-vocab in version 0.8.5
# File lib/active_fedora/file/attributes.rb, line 63 def fallback_digest_predicate @fallback_digest ||= if RDF::Vocab::Fcrepo4.respond_to? :digest RDF::Vocab::Fcrepo4.digest else ::RDF::URI("http://fedora.info/definitions/v4/repository#digest") end end
fetch_mime_type()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 79 def fetch_mime_type return default_mime_type if new_record? && metadata.mime_type.blank? metadata.mime_type.first end
fetch_original_name()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 84 def fetch_original_name return if new_record? ldp_source.head.content_disposition_filename end
links()
click to toggle source
# File lib/active_fedora/file/attributes.rb, line 71 def links @links ||= ldp_source.head.links end