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.



3
4
5
6
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 3

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

Instance Attribute Details

#abilityObject (readonly)

Returns the value of attribute ability.



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

def ability
  @ability
end

#userObject (readonly)

Returns the value of attribute user.



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

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



13
14
15
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 13

def current_user?
  user == ability.current_user
end

#eventsObject



17
18
19
20
21
22
23
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 17

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:



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

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