Class: Decidim::Initiatives::InitiativeSearch

Inherits:
ResourceSearch
  • Object
show all
Defined in:
decidim-initiatives/app/services/decidim/initiatives/initiative_search.rb

Overview

This service scopes the meeting searches with parameters that cannot be passed from the user interface.

Instance Attribute Summary collapse

Attributes inherited from ResourceSearch

#component, #organization, #search_context, #user

Instance Method Summary collapse

Methods inherited from ResourceSearch

#configure, #initialize

Constructor Details

This class inherits a constructor from Decidim::ResourceSearch

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



8
9
10
# File 'decidim-initiatives/app/services/decidim/initiatives/initiative_search.rb', line 8

def author
  @author
end

Instance Method Details

#build(params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'decidim-initiatives/app/services/decidim/initiatives/initiative_search.rb', line 10

def build(params)
  return super if search_context == :admin

  @author = params[:author]

  if params[:author] == "myself" && user
    add_scope(:authored_by, user)
  else
    add_scope(:published, nil)
  end

  super
end