Class: Hyrax::CompositePresenterFactory

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/hyrax/composite_presenter_factory.rb

Overview

Dynamic presenter which instantiates a file set presenter if given an object

with a given ID, but otherwise instantiates a work presenter.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_set_presenter_class, work_presenter_class, file_set_ids) ⇒ CompositePresenterFactory

Returns a new instance of CompositePresenterFactory.



8
9
10
11
12
# File 'app/presenters/hyrax/composite_presenter_factory.rb', line 8

def initialize(file_set_presenter_class, work_presenter_class, file_set_ids)
  @file_set_presenter_class = file_set_presenter_class
  @work_presenter_class = work_presenter_class
  @file_set_ids = file_set_ids
end

Instance Attribute Details

#file_set_idsObject (readonly)

Returns the value of attribute file_set_ids.



7
8
9
# File 'app/presenters/hyrax/composite_presenter_factory.rb', line 7

def file_set_ids
  @file_set_ids
end

#file_set_presenter_classObject (readonly)

Returns the value of attribute file_set_presenter_class.



7
8
9
# File 'app/presenters/hyrax/composite_presenter_factory.rb', line 7

def file_set_presenter_class
  @file_set_presenter_class
end

#work_presenter_classObject (readonly)

Returns the value of attribute work_presenter_class.



7
8
9
# File 'app/presenters/hyrax/composite_presenter_factory.rb', line 7

def work_presenter_class
  @work_presenter_class
end

Instance Method Details

#new(*args) ⇒ Object



14
15
16
17
18
19
20
21
# File 'app/presenters/hyrax/composite_presenter_factory.rb', line 14

def new(*args)
  obj = args.first
  if file_set_ids.include?(obj.id)
    file_set_presenter_class.new(*args)
  else
    work_presenter_class.new(*args)
  end
end