Class: CurationConcerns::MemberPresenterFactory

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/curation_concerns/member_presenter_factory.rb

Overview

Creates the presenters of the members (member works and file sets) of a specific object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(work, ability, request = nil) ⇒ MemberPresenterFactory

Returns a new instance of MemberPresenterFactory.



11
12
13
14
15
# File 'app/presenters/curation_concerns/member_presenter_factory.rb', line 11

def initialize(work, ability, request = nil)
  @work = work
  @current_ability = ability
  @request = request
end

Instance Attribute Details

#current_abilityObject (readonly)

Returns the value of attribute current_ability.



18
19
20
# File 'app/presenters/curation_concerns/member_presenter_factory.rb', line 18

def current_ability
  @current_ability
end

#requestObject (readonly)

Returns the value of attribute request.



18
19
20
# File 'app/presenters/curation_concerns/member_presenter_factory.rb', line 18

def request
  @request
end

Instance Method Details

#file_set_presentersArray<FileSetPresenter>

Returns presenters for the orderd_members that are FileSets.

Returns:

  • (Array<FileSetPresenter>)

    presenters for the orderd_members that are FileSets



28
29
30
# File 'app/presenters/curation_concerns/member_presenter_factory.rb', line 28

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).

Parameters:

  • ids (Array<String>) (defaults to: ordered_ids)

    a list of ids to build presenters for

  • presenter_class (Class) (defaults to: composite_presenter_class)

    the type of presenter to build

Returns:

  • (Array<presenter_class>)

    presenters for the ordered_members (not filtered by class)



23
24
25
# File 'app/presenters/curation_concerns/member_presenter_factory.rb', line 23

def member_presenters(ids = ordered_ids, presenter_class = composite_presenter_class)
  PresenterFactory.build_presenters(ids, presenter_class, *presenter_factory_arguments)
end

#work_presentersArray<WorkShowPresenter>

Returns presenters for the ordered_members that are not FileSets.

Returns:

  • (Array<WorkShowPresenter>)

    presenters for the ordered_members that are not FileSets



33
34
35
# File 'app/presenters/curation_concerns/member_presenter_factory.rb', line 33

def work_presenters
  @work_presenters ||= member_presenters(ordered_ids - file_set_ids, work_presenter_class)
end