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 ⇒ ::User readonly
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.
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
#ability ⇒ Object (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)
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.
23 24 25 |
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 23 def current_user? user == ability.current_user end |
#events ⇒ Object
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 |
#trophies ⇒ Array<TrophyPresenter>
Returns list of TrophyPresenters for this profile.
37 38 39 |
# File 'app/presenters/hyrax/user_profile_presenter.rb', line 37 def trophies @trophies ||= Hyrax::TrophyPresenter.find_by_user(user) end |