Class: Hyrax::MemberPresenterFactory

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_abilityObject (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

#requestObject (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_presentersArray<FileSetPresenter>

Returns presenters for the orderd_members that are FileSets.

Returns:

  • (Array<FileSetPresenter>)

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

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)



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_idsObject



40
41
42
# File 'app/presenters/hyrax/member_presenter_factory.rb', line 40

def ordered_ids
  @work.ordered_member_ids
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



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