Class: FeatureFlagsFinder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of FeatureFlagsFinder.


6
7
8
9
10
# File 'app/finders/feature_flags_finder.rb', line 6

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.


4
5
6
# File 'app/finders/feature_flags_finder.rb', line 4

def current_user
  @current_user
end

#paramsObject (readonly)

Returns the value of attribute params.


4
5
6
# File 'app/finders/feature_flags_finder.rb', line 4

def params
  @params
end

#projectObject (readonly)

Returns the value of attribute project.


4
5
6
# File 'app/finders/feature_flags_finder.rb', line 4

def project
  @project
end

Instance Method Details

#execute(preload: true) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
# File 'app/finders/feature_flags_finder.rb', line 12

def execute(preload: true)
  unless Ability.allowed?(current_user, :read_feature_flag, project)
    return Operations::FeatureFlag.none
  end

  items = feature_flags
  items = by_scope(items)

  items = items.preload_relations if preload
  items.ordered
end