Class: SmoothChange::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/smooth_change/feature.rb

Overview

A feature to be mentioned by a feature flag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, mode) ⇒ Feature

Returns a new instance of Feature.



9
10
11
12
# File 'lib/smooth_change/feature.rb', line 9

def initialize(name, mode)
  self.name = name
  self.mode = mode
end

Instance Attribute Details

#modeObject

Returns the value of attribute mode.



7
8
9
# File 'lib/smooth_change/feature.rb', line 7

def mode
  @mode
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/smooth_change/feature.rb', line 6

def name
  @name
end

Instance Method Details

#default_enabled_valueBoolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/smooth_change/feature.rb', line 34

def default_enabled_value
  mode == :opt_out
end

#enabled_with?(feature_toggler) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'lib/smooth_change/feature.rb', line 26

def enabled_with?(feature_toggler)
  value = feature_toggler.value_for(name)
  return default_enabled_value if value.nil?

  !!value
end