Module: ActiveFedora::File::Attributes

Included in:
ActiveFedora::File
Defined in:
lib/active_fedora/file/attributes.rb

Instance Method Summary collapse

Instance Method Details

#assign_attributes(_) ⇒ Object



4
5
6
# File 'lib/active_fedora/file/attributes.rb', line 4

def assign_attributes(_)
  # nop
end

#create_dateObject



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 && created.first
end

#digestObject



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_sizeObject



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

Returns:

  • (Boolean)


43
44
45
# File 'lib/active_fedora/file/attributes.rb', line 43

def empty?
  !has_content?
end

#has_content?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/active_fedora/file/attributes.rb', line 39

def has_content?
  size && size > 0
end

#mime_typeObject



8
9
10
# File 'lib/active_fedora/file/attributes.rb', line 8

def mime_type
  fetch_mime_type
end

#modified_dateObject



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 && modified.first
end

#original_nameObject



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_sizeObject



27
28
29
# File 'lib/active_fedora/file/attributes.rb', line 27

def persisted_size
  ldp_source.head.content_length unless new_record?
end

#sizeObject



35
36
37
# File 'lib/active_fedora/file/attributes.rb', line 35

def size
  dirty_size || persisted_size
end