Class: Hyrax::SelectTypeListPresenter
- Inherits:
-
Object
- Object
- Hyrax::SelectTypeListPresenter
- 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
- #authorized_models ⇒ Object
- #each {|presenter| ... } ⇒ Object
-
#first_model {|model| ... } ⇒ Class
Return or yield the first model in the list.
-
#initialize(current_user) ⇒ SelectTypeListPresenter
constructor
A new instance of SelectTypeListPresenter.
-
#many? ⇒ Boolean
Are there many differnt types to choose?.
Constructor Details
#initialize(current_user) ⇒ SelectTypeListPresenter
Returns a new instance of SelectTypeListPresenter.
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_models ⇒ Object
19 20 21 22 |
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 19 def return [] unless @current_user @authorized_models ||= Hyrax::QuickClassificationQuery.new(@current_user). end |
#each {|presenter| ... } ⇒ Object
35 36 37 |
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 35 def each .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.
29 30 31 32 |
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 29 def first_model yield(.first) if block_given? .first end |
#many? ⇒ Boolean
Returns are there many differnt types to choose?.
15 16 17 |
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 15 def many? .size > 1 end |