Class: Decidim::Initiatives::UserAuthorizations

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-initiatives/app/queries/decidim/initiatives/user_authorizations.rb

Overview

Class used the retrieve the authorizations for a user.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ UserAuthorizations

Retrieves authorizations for the given user

user - Decidim::User


19
20
21
# File 'decidim-initiatives/app/queries/decidim/initiatives/user_authorizations.rb', line 19

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user


7
8
9
# File 'decidim-initiatives/app/queries/decidim/initiatives/user_authorizations.rb', line 7

def user
  @user
end

Class Method Details

.for(user) ⇒ Object

Syntactic sugar to initialize the class and return the queried objects.

user - Decidim::User


12
13
14
# File 'decidim-initiatives/app/queries/decidim/initiatives/user_authorizations.rb', line 12

def self.for(user)
  new(user).query
end

Instance Method Details

#queryObject

Retrieves authorizations for the given user.


24
25
26
# File 'decidim-initiatives/app/queries/decidim/initiatives/user_authorizations.rb', line 24

def query
  Authorization.where(user: user).where.not(granted_at: nil)
end