Class: Decidim::Feeds::Admin::AdminUsers
- Inherits:
-
Query
- Object
- Query
- Decidim::Feeds::Admin::AdminUsers
- Defined in:
- app/queries/decidim/feeds/admin/admin_users.rb
Overview
A class used to find the admins for an feed or an organization feeds.
Class Method Summary collapse
-
.for(feed) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
-
.for_organization(organization) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(feed, organization = nil) ⇒ AdminUsers
constructor
Initializes the class.
-
#query ⇒ Object
Finds organization admins and the users with role admin for the given feed.
Constructor Details
#initialize(feed, organization = nil) ⇒ AdminUsers
Initializes the class.
feed - an feed that needs to find its feed admins organization - an organization that needs to find its feed admins
26 27 28 29 |
# File 'app/queries/decidim/feeds/admin/admin_users.rb', line 26 def initialize(feed, organization = nil) @feed = feed @organization = feed&.organization || organization end |
Class Method Details
.for(feed) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
feed - an feed that needs to find its feed admins
11 12 13 |
# File 'app/queries/decidim/feeds/admin/admin_users.rb', line 11 def self.for(feed) new(feed).query end |
.for_organization(organization) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
organization - an organization that needs to find its feed admins
18 19 20 |
# File 'app/queries/decidim/feeds/admin/admin_users.rb', line 18 def self.for_organization(organization) new(nil, organization).query end |
Instance Method Details
#query ⇒ Object
Finds organization admins and the users with role admin for the given feed.
Returns an ActiveRecord::Relation.
34 35 36 |
# File 'app/queries/decidim/feeds/admin/admin_users.rb', line 34 def query organization.admins.or(feeds_user_admins) end |