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)

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

def initialize(current_user)
  @current_user = current_user
end

Instance Method Details

#authorized_modelsObject


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

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

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

Yield Parameters:


35
36
37
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 35

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 model class

Returns:

  • (Class)

    a model class


29
30
31
32
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 29

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?


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

def many?
  authorized_models.size > 1
end