Class: Flipper::FeatureCheckContext

Inherits:
Object
  • Object
show all
Defined in:
lib/flipper/feature_check_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature_name:, values:, actors:) ⇒ FeatureCheckContext

Returns a new instance of FeatureCheckContext.



13
14
15
16
17
# File 'lib/flipper/feature_check_context.rb', line 13

def initialize(feature_name:, values:, actors:)
  @feature_name = feature_name
  @values = values
  @actors = actors
end

Instance Attribute Details

#actorsObject (readonly)

Public: The actors we want to know if a feature is enabled for.



11
12
13
# File 'lib/flipper/feature_check_context.rb', line 11

def actors
  @actors
end

#feature_nameObject (readonly)

Public: The name of the feature.



4
5
6
# File 'lib/flipper/feature_check_context.rb', line 4

def feature_name
  @feature_name
end

#valuesObject (readonly)

Public: The GateValues instance that keeps track of the values for the gates for the feature.



8
9
10
# File 'lib/flipper/feature_check_context.rb', line 8

def values
  @values
end

Instance Method Details

#actors?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/flipper/feature_check_context.rb', line 19

def actors?
  !@actors.nil? && !@actors.empty?
end

#actors_valueObject

Public: Convenience method for actors value value like Feature has.



29
30
31
# File 'lib/flipper/feature_check_context.rb', line 29

def actors_value
  values.actors
end

#boolean_valueObject

Public: Convenience method for boolean value value like Feature has.



34
35
36
# File 'lib/flipper/feature_check_context.rb', line 34

def boolean_value
  values.boolean
end

#groups_valueObject

Public: Convenience method for groups value like Feature has.



24
25
26
# File 'lib/flipper/feature_check_context.rb', line 24

def groups_value
  values.groups
end

#percentage_of_actors_valueObject

Public: Convenience method for percentage of actors value like Feature has.



39
40
41
# File 'lib/flipper/feature_check_context.rb', line 39

def percentage_of_actors_value
  values.percentage_of_actors
end

#percentage_of_time_valueObject

Public: Convenience method for percentage of time value like Feature has.



44
45
46
# File 'lib/flipper/feature_check_context.rb', line 44

def percentage_of_time_value
  values.percentage_of_time
end