Class: Decidim::Admin::UserFilter
- Inherits:
-
Query
- Object
- Query
- Decidim::Admin::UserFilter
- Defined in:
- app/queries/decidim/admin/user_filter.rb
Overview
A class used to filter users by whitelisted scope or searches on their name
Constant Summary collapse
- WHITELISTED_STATE_SCOPES =
%w( officialized not_officialized managed not_managed ).freeze
Class Method Summary collapse
-
.for(scope, name_query = nil, state = nil) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(scope, name_query = nil, state = nil) ⇒ UserFilter
constructor
Initializes the class.
-
#query ⇒ Object
List the User groups by the diferents filters.
Constructor Details
#initialize(scope, name_query = nil, state = nil) ⇒ UserFilter
Initializes the class.
scope - the ActiveRecord::Relation of users to be filtered name_query - query to filter user group names state - users state, must be defined as a scope in the user model
29 30 31 32 33 |
# File 'app/queries/decidim/admin/user_filter.rb', line 29 def initialize(scope, name_query = nil, state = nil) @scope = scope @name_query = name_query @state = state end |
Class Method Details
.for(scope, name_query = nil, state = nil) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
scope - the ActiveRecord::Relation of users to be filtered name_query - query to filter user group names state - evaluation state to be used as a filter
20 21 22 |
# File 'app/queries/decidim/admin/user_filter.rb', line 20 def self.for(scope, name_query = nil, state = nil) new(scope, name_query, state).query end |
Instance Method Details
#query ⇒ Object
List the User groups by the diferents filters.
36 37 38 39 40 |
# File 'app/queries/decidim/admin/user_filter.rb', line 36 def query users = scope users = filter_by_search(users) filter_by_state(users) end |