Sha256: f184690485e1e5208d6905d0ea777f2817c0842b2eb6450140258b6decb071e1

Contents?: true

Size: 929 Bytes

Versions: 19

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  class UserProfilePresenter
    ##
    # @param user [::User]
    # @param ability [::Ability]
    def initialize(user, ability)
      @user = user
      @ability = ability
    end

    ##
    # @!attribute [r] ability
    #   @return [::Ability]
    # @!attribute [r] user
    #   @return [::User]
    attr_reader :user, :ability

    delegate :name, to: :user

    ##
    # @return [Boolean] true if the presenter is for the logged in user
    def current_user?
      user == ability.current_user
    end

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

    ##
    # @return [Array<TrophyPresenter>] list of TrophyPresenters for this profile.
    def trophies
      @trophies ||= Hyrax::TrophyPresenter.find_by_user(user)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/presenters/hyrax/user_profile_presenter.rb
hyrax-5.0.0 app/presenters/hyrax/user_profile_presenter.rb
hyrax-5.0.0.rc3 app/presenters/hyrax/user_profile_presenter.rb
hyrax-5.0.0.rc2 app/presenters/hyrax/user_profile_presenter.rb
hyrax-5.0.0.rc1 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.6.0 app/presenters/hyrax/user_profile_presenter.rb
hyrax-4.0.0 app/presenters/hyrax/user_profile_presenter.rb
hyrax-4.0.0.rc3 app/presenters/hyrax/user_profile_presenter.rb
hyrax-4.0.0.rc2 app/presenters/hyrax/user_profile_presenter.rb
hyrax-4.0.0.rc1 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.5.0 app/presenters/hyrax/user_profile_presenter.rb
hyrax-4.0.0.beta2 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.4.2 app/presenters/hyrax/user_profile_presenter.rb
hyrax-4.0.0.beta1 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.4.1 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.4.0 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.3.0 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.2.0 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.1.0 app/presenters/hyrax/user_profile_presenter.rb