Class: Decidim::Debates::DebateSearch

Inherits:
ResourceSearch
  • Object
show all
Defined in:
app/services/decidim/debates/debate_search.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#activityObject (readonly)

Returns the value of attribute activity.



8
9
10
# File 'app/services/decidim/debates/debate_search.rb', line 8

def activity
  @activity
end

Instance Method Details

#build(params) ⇒ Object



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

def build(params)
  @activity = params[:activity]

  if params[:activity] && user
    case params[:activity]
    when "commented"
      add_scope(:commented_by, user)
    when "my_debates"
      add_scope(:authored_by, user)
    end
  end

  super
end