Sha256: 4a680318fbb2ce582cca599cf5006dc77adc9d5a8ca73fb45a4ee687046d3fc2

Contents?: true

Size: 556 Bytes

Versions: 58

Compression:

Stored size: 556 Bytes

Contents

module Hyrax
  class VersionListPresenter
    def initialize(version_list)
      @raw_list = version_list
    end

    delegate :each, to: :wrapped_list

    private

      def wrapped_list
        @wrapped_list ||=
          @raw_list.map { |v| Hyrax::VersionPresenter.new(v) } # wrap each item in a presenter
                   .sort { |a, b| b.version.created <=> a.version.created } # sort list of versions based on creation date
                   .tap { |l| l.first.try(:current!) } # set the first version to the current version
      end
  end
end

Version data entries

58 entries across 58 versions & 2 rubygems

Version Path
hyrax-2.9.6 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.9.5 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.9.4 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.9.3 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.9.2 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.9.1 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.9.0 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.8.0 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.7.2 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.7.1 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.7.0 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.6.0 app/presenters/hyrax/version_list_presenter.rb
hyrax-3.0.0.pre.rc1 app/presenters/hyrax/version_list_presenter.rb
hyrax-3.0.0.pre.beta3 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.5.1 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.5.0 app/presenters/hyrax/version_list_presenter.rb
hyrax-3.0.0.pre.beta2 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.4.1 app/presenters/hyrax/version_list_presenter.rb
hyrax-3.0.0.pre.beta1 app/presenters/hyrax/version_list_presenter.rb
hyrax-2.4.0 app/presenters/hyrax/version_list_presenter.rb