Class: Decidim::Initiatives::InitiativesCreated

Inherits:
Rectify::Query
  • Object
show all
Defined in:
decidim-initiatives/app/queries/decidim/initiatives/initiatives_created.rb

Overview

Class uses to retrieve the initiatives created by the given user.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ InitiativesCreated

Initializes the class.

user: Decidim::User


19
20
21
# File 'decidim-initiatives/app/queries/decidim/initiatives/initiatives_created.rb', line 19

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user


7
8
9
# File 'decidim-initiatives/app/queries/decidim/initiatives/initiatives_created.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 'decidim-initiatives/app/queries/decidim/initiatives/initiatives_created.rb', line 12

def self.by(user)
  new(user).query
end

Instance Method Details

#queryObject

Retrieves the initiatives created by the given user


24
25
26
# File 'decidim-initiatives/app/queries/decidim/initiatives/initiatives_created.rb', line 24

def query
  Initiative.where(author: user)
end