Class: Hyrax::HomepagePresenter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_ability, collections) ⇒ HomepagePresenter

Returns a new instance of HomepagePresenter.


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

def initialize(current_ability, collections)
  @current_ability = current_ability
  @collections = collections
end

Instance Attribute Details

#collectionsObject (readonly)

Returns the value of attribute collections


5
6
7
# File 'app/presenters/hyrax/homepage_presenter.rb', line 5

def collections
  @collections
end

#current_abilityObject (readonly)

Returns the value of attribute current_ability


5
6
7
# File 'app/presenters/hyrax/homepage_presenter.rb', line 5

def current_ability
  @current_ability
end

Instance Method Details

#create_many_work_types?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'app/presenters/hyrax/homepage_presenter.rb', line 26

def create_many_work_types?
  create_work_presenter.many?
end

#create_work_presenterObject

A presenter for selecting a work type to create this is needed here because the selector is in the header on every page


22
23
24
# File 'app/presenters/hyrax/homepage_presenter.rb', line 22

def create_work_presenter
  @create_work_presenter ||= create_work_presenter_class.new(current_ability.current_user)
end

#display_share_button?Boolean

Returns If the current user is a guest and the display_share_button_when_not_logged_in? is activated, then return true. Otherwise return true if the signed in user has permission to create at least one kind of work.

Returns:

  • (Boolean)

    If the current user is a guest and the display_share_button_when_not_logged_in? is activated, then return true. Otherwise return true if the signed in user has permission to create at least one kind of work.


15
16
17
18
# File 'app/presenters/hyrax/homepage_presenter.rb', line 15

def display_share_button?
  (user_unregistered? && Hyrax.config.display_share_button_when_not_logged_in?) ||
    current_ability.can_create_any_work?
end

#draw_select_work_modal?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'app/presenters/hyrax/homepage_presenter.rb', line 30

def draw_select_work_modal?
  display_share_button? && create_many_work_types?
end

#first_work_typeObject


34
35
36
# File 'app/presenters/hyrax/homepage_presenter.rb', line 34

def first_work_type
  create_work_presenter.first_model
end