Class: Hyrax::UserProfilePresenter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, ability) ⇒ UserProfilePresenter

Returns a new instance of UserProfilePresenter.

Parameters:

  • user (::User)
  • ability (::Ability)

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

def initialize(user, ability)
  @user = user
  @ability = ability
end

Instance Attribute Details

#abilityObject (readonly)

Returns the value of attribute ability.


17
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 17

attr_reader :user, :ability

#user::User (readonly)

Returns:

  • (::User)

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

def user
  @user
end

Instance Method Details

#current_user?Boolean

Returns true if the presenter is for the logged in user.

Returns:

  • (Boolean)

    true if the presenter is for the logged in user


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

def current_user?
  user == ability.current_user
end

#eventsObject


27
28
29
30
31
32
33
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 27

def events
  @events ||= if user.respond_to? :profile_events
                user.profile_events(100)
              else
                []
              end
end

#trophiesArray<TrophyPresenter>

Returns list of TrophyPresenters for this profile.

Returns:


37
38
39
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 37

def trophies
  @trophies ||= Hyrax::TrophyPresenter.find_by_user(user)
end