Class: TodosFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/todos_finder.rb

Overview

TodosFinder

Used to filter Todos by set of params

Arguments:

current_user - which user use
params:
  action_id: integer
  author_id: integer
  project_id; integer
  state: 'pending' or 'done'
  type: 'Issue' or 'MergeRequest'

Constant Summary collapse

NONE =
'0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user, params) ⇒ TodosFinder

Returns a new instance of TodosFinder


20
21
22
23
# File 'app/finders/todos_finder.rb', line 20

def initialize(current_user, params)
  @current_user = current_user
  @params = params
end

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user


18
19
20
# File 'app/finders/todos_finder.rb', line 18

def current_user
  @current_user
end

#paramsObject

Returns the value of attribute params


18
19
20
# File 'app/finders/todos_finder.rb', line 18

def params
  @params
end

Instance Method Details

#executeObject


25
26
27
28
29
30
31
32
33
34
# File 'app/finders/todos_finder.rb', line 25

def execute
  items = current_user.todos
  items = by_action_id(items)
  items = by_author(items)
  items = by_project(items)
  items = by_state(items)
  items = by_type(items)

  items
end