Class: Hyrax::UserProfilePresenter
- Inherits:
-
Object
- Object
- Hyrax::UserProfilePresenter
- Defined in:
- app/presenters/hyrax/user_profile_presenter.rb
Instance Attribute Summary collapse
-
#ability ⇒ Object
readonly
Returns the value of attribute ability.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#current_user? ⇒ Boolean
True if the presenter is for the logged in user.
- #events ⇒ Object
-
#initialize(user, ability) ⇒ UserProfilePresenter
constructor
A new instance of UserProfilePresenter.
-
#trophies ⇒ Array<TrophyPresenter>
List of TrophyPresenters for this profile.
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
#ability ⇒ Object (readonly)
Returns the value of attribute ability.
8 9 10 |
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 8 def ability @ability end |
#user ⇒ Object (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.
13 14 15 |
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 13 def current_user? user == ability.current_user end |
#events ⇒ Object
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 |
#trophies ⇒ Array<TrophyPresenter>
Returns list of TrophyPresenters for this profile.
26 27 28 |
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 26 def trophies @trophies ||= Hyrax::TrophyPresenter.find_by_user(user) end |