Class: Hyrax::SelectTypeListPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/hyrax/select_type_list_presenter.rb

Overview

Presents the list of work type options that a user may choose from when deciding to create a new work

Instance Method Summary collapse

Constructor Details

#initialize(current_user) ⇒ SelectTypeListPresenter

Returns a new instance of SelectTypeListPresenter.

Parameters:

  • current_user (User)


6
7
8
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 6

def initialize(current_user)
  @current_user = current_user
end

Instance Method Details

#authorized_modelsObject



18
19
20
21
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 18

def authorized_models
  return [] unless @current_user
  @authorized_models ||= Hyrax::QuickClassificationQuery.new(@current_user).authorized_models
end

#each {|presenter| ... } ⇒ Object

Yield Parameters:



33
34
35
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 33

def each
  authorized_models.each { |model| yield row_presenter.new(model) }
end

#first_model {|model| ... } ⇒ Class

Return or yield the first model in the list. This is used when the list only has a single element.

Yield Parameters:

  • model (Class)

    a class that decends from ActiveFedora::Base

Returns:

  • (Class)

    a class that decends from ActiveFedora::Base



27
28
29
30
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 27

def first_model
  yield(authorized_models.first) if block_given?
  authorized_models.first
end

#many?Boolean

Returns are there many differnt types to choose?.

Returns:

  • (Boolean)

    are there many differnt types to choose?



14
15
16
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 14

def many?
  authorized_models.size > 1
end