Class: Hyrax::Riiif::File

Inherits:
Riiif::File
  • Object
show all
Includes:
ActiveSupport::Benchmarkable
Defined in:
app/models/hyrax/riiif/file.rb,
app/models/hyrax/riiif/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFile

Returns a new instance of File.

Raises:

  • (ArgumentError)


10
11
12
13
14
# File 'app/models/hyrax/riiif/file.rb', line 10

def initialize(input_path, tempfile = nil, id:)
  super(input_path, tempfile)
  raise(ArgumentError, "must specify id") if id.blank?
  @id = id
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'app/models/hyrax/riiif/file.rb', line 8

def id
  @id
end

Instance Method Details

#extract(transformation, image_info = nil) ⇒ Object

Wrap extract in a read lock and benchmark it



17
18
19
20
21
22
23
# File 'app/models/hyrax/riiif/file.rb', line 17

def extract(transformation, image_info = nil)
  ::Riiif::Image.file_resolver.file_locks[id].with_read_lock do
    benchmark "Hyrax::Riiif::File extracted #{path} with #{transformation.to_params}", level: :debug do
      super
    end
  end
end