Class: Environments::EnvironmentsFinder

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

Constant Summary collapse

InvalidStatesError =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project, current_user, params = {}) ⇒ EnvironmentsFinder

Returns a new instance of EnvironmentsFinder.


9
10
11
12
13
# File 'app/finders/environments/environments_finder.rb', line 9

def initialize(project, current_user, params = {})
  @project = project
  @current_user = current_user
  @params = params
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.


5
6
7
# File 'app/finders/environments/environments_finder.rb', line 5

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params.


5
6
7
# File 'app/finders/environments/environments_finder.rb', line 5

def params
  @params
end

#projectObject (readonly)

Returns the value of attribute project.


5
6
7
# File 'app/finders/environments/environments_finder.rb', line 5

def project
  @project
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
23
# File 'app/finders/environments/environments_finder.rb', line 15

def execute
  environments = project.environments
  environments = by_name(environments)
  environments = by_search(environments)
  environments = by_ids(environments)

  # Raises InvalidStatesError if params[:states] contains invalid states.
  by_states(environments)
end