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.


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

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


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

def file_set_ids
  @file_set_ids
end

#file_set_presenter_classObject (readonly)

Returns the value of attribute file_set_presenter_class


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

def file_set_presenter_class
  @file_set_presenter_class
end

#work_presenter_classObject (readonly)

Returns the value of attribute work_presenter_class


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

def work_presenter_class
  @work_presenter_class
end

Instance Method Details

#new(*args) ⇒ Object


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

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