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.
5 6 7 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 5 def initialize(current_user) @current_user = current_user end |
Instance Method Details
#any? ⇒ Boolean
Returns are there any authorized types?.
18 19 20 21 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 18 def any? return true if .present? false end |
#authorized_collection_types ⇒ Object
Return an array of authorized collection types.
24 25 26 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 24 def @authorized_collection_types ||= Hyrax::CollectionTypes::PermissionsService.can_create_collection_types(user: @current_user) end |
#each {|a| ... } ⇒ Object
38 39 40 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 38 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.
32 33 34 35 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 32 def first_collection_type yield(.first) if block_given? .first end |
#many? ⇒ Boolean
Returns are there many different types to choose?.
13 14 15 |
# File 'app/presenters/hyrax/select_collection_type_list_presenter.rb', line 13 def many? .size > 1 end |