Sha256: 88d072ffb00cd71a6063cf25607ab07337e0f9531a6c6aeb90bd5cdb851c22e3
Contents?: true
Size: 1.13 KB
Versions: 29
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Hyrax # Presents the list of work type options that a user may choose from when deciding to # create a new work class SelectTypeListPresenter # @param current_user [User] def initialize(current_user) @current_user = current_user end class_attribute :row_presenter self.row_presenter = SelectTypePresenter # @return [Boolean] are there many differnt types to choose? def many? authorized_models.size > 1 end def authorized_models return [] unless @current_user @authorized_models ||= Hyrax::QuickClassificationQuery.new(@current_user).authorized_models end # Return or yield the first model in the list. This is used when the list # only has a single element. # # @yieldparam [Class] model a model class # @return [Class] a model class def first_model yield(authorized_models.first) if block_given? authorized_models.first end # @yieldparam [SelectTypePresenter] presenter a presenter for the item def each authorized_models.each { |model| yield row_presenter.new(model) } end end end
Version data entries
29 entries across 29 versions & 1 rubygems