Sha256: 69df9fcb7c78aa46da0d69801eafbe65b8ea569eaf97000083d28e56d45f60d9

Contents?: true

Size: 750 Bytes

Versions: 29

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  ##
  # Dynamic presenter which instantiates a file set presenter if given an object
  #   with a given ID, but otherwise instantiates a work presenter.
  class CompositePresenterFactory
    attr_reader :file_set_presenter_class, :work_presenter_class, :file_set_ids
    def initialize(file_set_presenter_class, work_presenter_class, file_set_ids)
      @file_set_presenter_class = file_set_presenter_class
      @work_presenter_class = work_presenter_class
      @file_set_ids = file_set_ids
    end

    def new(*args)
      obj = args.first
      if file_set_ids.include?(obj.id)
        file_set_presenter_class.new(*args)
      else
        work_presenter_class.new(*args)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-5.0.4 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-5.0.3 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-5.0.2 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-5.0.1 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-5.0.0 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-5.0.0.rc3 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-5.0.0.rc2 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-5.0.0.rc1 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-3.6.0 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-4.0.0 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-4.0.0.rc3 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-4.0.0.rc2 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-4.0.0.rc1 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-3.5.0 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-4.0.0.beta2 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-3.4.2 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-4.0.0.beta1 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-3.4.1 app/presenters/hyrax/composite_presenter_factory.rb
hyrax-3.4.0 app/presenters/hyrax/composite_presenter_factory.rb