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.


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

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

Instance Attribute Details

#collectionsObject (readonly)

Returns the value of attribute collections


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

def collections
  @collections
end

#current_abilityObject (readonly)

Returns the value of attribute current_ability


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

def current_ability
  @current_ability
end

Instance Method Details

#create_many_work_types?Boolean

Returns:

  • (Boolean)

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

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


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

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.


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

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)

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

def draw_select_work_modal?
  display_share_button? && create_many_work_types?
end

#first_work_typeObject


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

def first_work_type
  create_work_presenter.first_model
end