Class: Flip::FeaturesController::FeaturesPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/flip/features_controller.rb

Instance Method Summary collapse

Constructor Details

#initialize(feature_set) ⇒ FeaturesPresenter

Returns a new instance of FeaturesPresenter.



12
13
14
# File 'app/controllers/flip/features_controller.rb', line 12

def initialize(feature_set)
  @feature_set = feature_set
end

Instance Method Details

#default_status(definition) ⇒ Object



28
29
30
# File 'app/controllers/flip/features_controller.rb', line 28

def default_status(definition)
  @feature_set.default_for(definition) ? "on" : "off"
end

#definitionsObject



20
21
22
# File 'app/controllers/flip/features_controller.rb', line 20

def definitions
  @feature_set.definitions
end

#status(definition) ⇒ Object



24
25
26
# File 'app/controllers/flip/features_controller.rb', line 24

def status(definition)
  @feature_set.on?(definition.key) ? "on" : "off"
end

#strategiesObject



16
17
18
# File 'app/controllers/flip/features_controller.rb', line 16

def strategies
  @feature_set.strategies
end

#strategy_status(strategy, definition) ⇒ Object



32
33
34
35
36
# File 'app/controllers/flip/features_controller.rb', line 32

def strategy_status(strategy, definition)
  if strategy.knows? definition
    strategy.on?(definition) ? "on" : "off"
  end
end

#switch_url(strategy, definition) ⇒ Object



38
39
40
41
42
# File 'app/controllers/flip/features_controller.rb', line 38

def switch_url(strategy, definition)
  feature_strategy_path \
    definition.key,
    strategy.name.underscore
end