Module: ActiveFedora::File::Attributes
- Included in:
 - ActiveFedora::File
 
- Defined in:
 - lib/active_fedora/file/attributes.rb
 
Instance Method Summary collapse
- #assign_attributes(_) ⇒ Object
 - #create_date ⇒ Object
 - #digest ⇒ Object
 - #dirty_size ⇒ Object
 - #empty? ⇒ Boolean
 - #has_content? ⇒ Boolean
 - #mime_type ⇒ Object
 - #modified_date ⇒ Object
 - #original_name ⇒ Object
 - #original_name=(name) ⇒ Object
 - #persisted_size ⇒ Object
 - #size ⇒ Object
 
Instance Method Details
#assign_attributes(_) ⇒ Object
      4 5 6  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 4 def assign_attributes(_) # nop end  | 
  
#create_date ⇒ Object
      47 48 49 50  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 47 def create_date created = .attributes["http://fedora.info/definitions/v4/repository#created"] created&.first end  | 
  
#digest ⇒ Object
      20 21 22 23 24 25  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 20 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
      31 32 33  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 31 def dirty_size content.size if content_changed? && content.respond_to?(:size) end  | 
  
#empty? ⇒ Boolean
      43 44 45  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 43 def empty? !has_content? end  | 
  
#has_content? ⇒ Boolean
      39 40 41  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 39 def has_content? size&.positive? end  | 
  
#mime_type ⇒ Object
      8 9 10  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 8 def mime_type fetch_mime_type end  | 
  
#modified_date ⇒ Object
      52 53 54 55  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 52 def modified_date modified = .attributes["http://fedora.info/definitions/v4/repository#lastModified"] modified&.first end  | 
  
#original_name ⇒ Object
      12 13 14  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 12 def original_name @original_name ||= fetch_original_name end  | 
  
#original_name=(name) ⇒ Object
      16 17 18  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 16 def original_name=(name) @original_name = name end  | 
  
#persisted_size ⇒ Object
      27 28 29  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 27 def persisted_size ldp_source.head.content_length unless new_record? end  | 
  
#size ⇒ Object
      35 36 37  | 
    
      # File 'lib/active_fedora/file/attributes.rb', line 35 def size dirty_size || persisted_size end  |