Class: Hyrax::VersionListPresenter

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
app/presenters/hyrax/version_list_presenter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ VersionListPresenter

Returns a new instance of VersionListPresenter.

Parameters:



12
13
14
# File 'app/presenters/hyrax/version_list_presenter.rb', line 12

def initialize(service)
  @versioning_service = service
end

Instance Attribute Details

#versioning_serviceObject (readonly)



8
9
10
# File 'app/presenters/hyrax/version_list_presenter.rb', line 8

def versioning_service
  @versioning_service
end

Class Method Details

.for(file_set:, file_service: Hyrax.config.file_set_file_service) ⇒ Hyrax::VersionListPresenter

Returns an enumerable of presenters for the relevant file versions.

Parameters:

  • an (Object)

    object representing the File Set

Returns:

Raises:

  • (ArgumentError)

    if we can’t build an enumerable



23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/presenters/hyrax/version_list_presenter.rb', line 23

def self.for(file_set:, file_service: Hyrax.config.file_set_file_service)
  original_file = case file_set
                  when ActiveFedora::Base
                    file_set.original_file
                  else
                    file_service.new(file_set: file_set).primary_file
                  end

  new(Hyrax::VersioningService.new(resource: original_file))
rescue NoMethodError
  raise ArgumentError
end