Class: Hyrax::MemberPresenterFactory
- Inherits:
-
Object
- Object
- Hyrax::MemberPresenterFactory
- Defined in:
- app/presenters/hyrax/member_presenter_factory.rb
Overview
Creates the presenters of the members (member works and file sets) of a specific object
Instance Attribute Summary collapse
-
#current_ability ⇒ Object
readonly
Returns the value of attribute current_ability.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#file_set_presenters ⇒ Array<FileSetPresenter>
Presenters for the orderd_members that are FileSets.
-
#initialize(work, ability, request = nil) ⇒ MemberPresenterFactory
constructor
A new instance of MemberPresenterFactory.
-
#member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class) ⇒ Array<presenter_class>
Presenters for the ordered_members (not filtered by class).
- #ordered_ids ⇒ Object
-
#work_presenters ⇒ Array<WorkShowPresenter>
Presenters for the ordered_members that are not FileSets.
Constructor Details
#initialize(work, ability, request = nil) ⇒ MemberPresenterFactory
Returns a new instance of MemberPresenterFactory.
12 13 14 15 16 |
# File 'app/presenters/hyrax/member_presenter_factory.rb', line 12 def initialize(work, ability, request = nil) @work = Hyrax::SolrDocument::OrderedMembers.decorate(work) @current_ability = ability @request = request end |
Instance Attribute Details
#current_ability ⇒ Object (readonly)
Returns the value of attribute current_ability.
19 20 21 |
# File 'app/presenters/hyrax/member_presenter_factory.rb', line 19 def current_ability @current_ability end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
19 20 21 |
# File 'app/presenters/hyrax/member_presenter_factory.rb', line 19 def request @request end |
Instance Method Details
#file_set_presenters ⇒ Array<FileSetPresenter>
Returns presenters for the orderd_members that are FileSets.
31 32 33 |
# File 'app/presenters/hyrax/member_presenter_factory.rb', line 31 def file_set_presenters @file_set_presenters ||= member_presenters(ordered_ids & file_set_ids) end |
#member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class) ⇒ Array<presenter_class>
Returns presenters for the ordered_members (not filtered by class).
24 25 26 27 28 |
# File 'app/presenters/hyrax/member_presenter_factory.rb', line 24 def member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class) PresenterFactory.build_for(ids: ids, presenter_class: presenter_class, presenter_args: presenter_factory_arguments) end |
#ordered_ids ⇒ Object
40 41 42 |
# File 'app/presenters/hyrax/member_presenter_factory.rb', line 40 def ordered_ids @work.ordered_member_ids end |
#work_presenters ⇒ Array<WorkShowPresenter>
Returns presenters for the ordered_members that are not FileSets.
36 37 38 |
# File 'app/presenters/hyrax/member_presenter_factory.rb', line 36 def work_presenters @work_presenters ||= member_presenters(ordered_ids - file_set_ids, work_presenter_class) end |