Class: Hyrax::SelectCollectionTypeListPresenter
- Inherits:
-
Object
- Object
- Hyrax::SelectCollectionTypeListPresenter
- Defined in:
- app/presenters/hyrax/select_collection_type_list_presenter.rb
Overview
Presents the list of collection type options that a user may choose from when deciding to create a new work
Instance Method Summary collapse
-
#any? ⇒ Boolean
Are there any authorized types?.
-
#authorized_collection_types ⇒ Object
Return an array of authorized collection types.
- #each {|a| ... } ⇒ Object
-
#first_collection_type {|a| ... } ⇒ CollectionType
Return or yield the first type in the list.
-
#initialize(current_user) ⇒ SelectCollectionTypeListPresenter
constructor
A new instance of SelectCollectionTypeListPresenter.
-
#many? ⇒ Boolean
Are there many different types to choose?.
Constructor Details
#initialize(current_user) ⇒ SelectCollectionTypeListPresenter
Returns a new instance of SelectCollectionTypeListPresenter.
6 7 8 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 6 def initialize(current_user) @current_user = current_user end |
Instance Method Details
#any? ⇒ Boolean
Returns are there any authorized types?.
19 20 21 22 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 19 def any? return true if .present? false end |
#authorized_collection_types ⇒ Object
Return an array of authorized collection types.
25 26 27 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 25 def @authorized_collection_types ||= Hyrax::CollectionTypes::PermissionsService.can_create_collection_types(user: @current_user) end |
#each {|a| ... } ⇒ Object
39 40 41 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 39 def each .each { |type| yield row_presenter.new(type) } end |
#first_collection_type {|a| ... } ⇒ CollectionType
Return or yield the first type in the list. This is used when the list only has a single element.
33 34 35 36 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 33 def first_collection_type yield(.first) if block_given? .first end |
#many? ⇒ Boolean
Returns are there many different types to choose?.
14 15 16 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 14 def many? .size > 1 end |