Module: ActiveFedora::File::Attributes

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

Instance Method Summary collapse

Instance Method Details

#create_dateObject



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

#digestObject



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_sizeObject



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

def dirty_size
  content.size if content_changed? && content.respond_to?(:size)
end

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  !has_content?
end

#has_content?Boolean

Returns:

  • (Boolean)


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

def has_content?
  size && size > 0
end

#mime_typeObject



2
3
4
# File 'lib/active_fedora/file/attributes.rb', line 2

def mime_type
  fetch_mime_type
end

#original_nameObject



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_sizeObject



23
24
25
# File 'lib/active_fedora/file/attributes.rb', line 23

def persisted_size
  ldp_source.head.content_length unless new_record?
end

#sizeObject



31
32
33
# File 'lib/active_fedora/file/attributes.rb', line 31

def size
  dirty_size || persisted_size
end