Class: Decidim::Verifications::Authorizations
- Inherits:
-
Rectify::Query
- Object
- Rectify::Query
- Decidim::Verifications::Authorizations
- Defined in:
- app/queries/decidim/verifications/authorizations.rb
Overview
Finds authorizations by different criteria
Instance Method Summary collapse
-
#initialize(user: nil, name: nil, granted: nil) ⇒ Authorizations
constructor
Initializes the class.
-
#query ⇒ Object
Finds the Authorizations for the given method.
Constructor Details
#initialize(user: nil, name: nil, granted: nil) ⇒ Authorizations
Initializes the class.
12 13 14 15 16 |
# File 'app/queries/decidim/verifications/authorizations.rb', line 12 def initialize(user: nil, name: nil, granted: nil) @user = user @name = name @granted = granted end |
Instance Method Details
#query ⇒ Object
Finds the Authorizations for the given method
Returns an ActiveRecord::Relation.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/queries/decidim/verifications/authorizations.rb', line 21 def query scope = Decidim::Authorization.where(nil) scope = scope.where(name: name) unless name.nil? scope = scope.where(user: user) unless user.nil? if granted == true scope = scope.where.not(granted_at: nil) elsif granted == false scope = scope.where(granted_at: nil) end scope end |