Class: Decidim::Initiatives::InitiativesPromoted
- Inherits:
-
Query
- Object
- Query
- Decidim::Initiatives::InitiativesPromoted
- Defined in:
- app/queries/decidim/initiatives/initiatives_promoted.rb
Overview
Class uses to retrieve initiatives promoted by the given user
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
-
.by(user) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
Instance Method Summary collapse
-
#initialize(user) ⇒ InitiativesPromoted
constructor
Initializes the class.
-
#query ⇒ Object
Retrieves the initiatives promoted by the given user.
Constructor Details
#initialize(user) ⇒ InitiativesPromoted
Initializes the class.
user: Decidim::User
19 20 21 |
# File 'app/queries/decidim/initiatives/initiatives_promoted.rb', line 19 def initialize(user) @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'app/queries/decidim/initiatives/initiatives_promoted.rb', line 7 def user @user end |
Class Method Details
.by(user) ⇒ Object
Syntactic sugar to initialize the class and return the queried objects.
user - Decidim::User
12 13 14 |
# File 'app/queries/decidim/initiatives/initiatives_promoted.rb', line 12 def self.by(user) new(user).query end |
Instance Method Details
#query ⇒ Object
Retrieves the initiatives promoted by the given user.
24 25 26 27 28 29 |
# File 'app/queries/decidim/initiatives/initiatives_promoted.rb', line 24 def query Initiative .joins(:committee_members) .where("decidim_initiatives_committee_members.state = 2") .where(decidim_initiatives_committee_members: { decidim_users_id: user.id }) end |