Sha256: 1c0b3f320cf9da9a9adf677408afdb89781f0c6e0be1dff3d91c2524b9ba46e7

Contents?: true

Size: 720 Bytes

Versions: 58

Compression:

Stored size: 720 Bytes

Contents

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

58 entries across 58 versions & 2 rubygems

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