Sha256: aa2a51ecc7c829ce3e93f2e1d73bebea67525d4fb2258c62fde74071500b86bd

Contents?: true

Size: 721 Bytes

Versions: 6

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  class UserProfilePresenter
    def initialize(user, ability)
      @user = user
      @ability = ability
    end

    attr_reader :user, :ability

    delegate :name, to: :user

    # @return 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

6 entries across 6 versions & 1 rubygems

Version Path
hyrax-3.0.2 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.0.1 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.0.0 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.0.0.pre.rc4 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.0.0.pre.rc3 app/presenters/hyrax/user_profile_presenter.rb
hyrax-3.0.0.pre.rc2 app/presenters/hyrax/user_profile_presenter.rb