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.
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_models ⇒ Object
18 19 20 21 |
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 18 def return [] unless @current_user @authorized_models ||= Hyrax::QuickClassificationQuery.new(@current_user). end |
#each {|presenter| ... } ⇒ Object
33 34 35 |
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 33 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.
27 28 29 30 |
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 27 def first_model yield(.first) if block_given? .first end |
#many? ⇒ Boolean
Returns are there many differnt types to choose?.
14 15 16 |
# File 'app/presenters/hyrax/select_type_list_presenter.rb', line 14 def many? .size > 1 end |