Class: UserApplicationsPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/user_applications_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ UserApplicationsPresenter

Returns a new instance of UserApplicationsPresenter.


4
5
6
# File 'app/presenters/user_applications_presenter.rb', line 4

def initialize(user)
  @user = user
end

Instance Method Details

#applications?Boolean

Returns:

  • (Boolean)

19
20
21
# File 'app/presenters/user_applications_presenter.rb', line 19

def applications?
  applications_count > 0
end

#applications_countObject


15
16
17
# File 'app/presenters/user_applications_presenter.rb', line 15

def applications_count
  user_applications.size
end

#user_applicationsObject


8
9
10
11
12
13
# File 'app/presenters/user_applications_presenter.rb', line 8

def user_applications
  @applications ||= @user.o_auth_applications.map do |app|
    authorization = Api::OpenidConnect::Authorization.find_by_client_id_and_user(app.client_id, @user)
    UserApplicationPresenter.new app, authorization.scopes, authorization.id
  end
end