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