Class: Flipflop::FeaturesController::FeaturesPresenter

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

Instance Method Summary collapse

Constructor Details

#initialize(feature_set) ⇒ FeaturesPresenter

Returns a new instance of FeaturesPresenter.



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

def initialize(feature_set)
  @cache = {}
  @feature_set = feature_set
end

Instance Method Details

#featuresObject



25
26
27
# File 'app/controllers/flipflop/features_controller.rb', line 25

def features
  @feature_set.features
end

#status(feature) ⇒ Object



29
30
31
32
33
# File 'app/controllers/flipflop/features_controller.rb', line 29

def status(feature)
  cache(nil, feature) do
    status_to_s(@feature_set.enabled?(feature.key))
  end
end

#strategiesObject



21
22
23
# File 'app/controllers/flipflop/features_controller.rb', line 21

def strategies
  @feature_set.strategies.reject(&:hidden?)
end

#strategy_status(strategy, feature) ⇒ Object



35
36
37
38
39
# File 'app/controllers/flipflop/features_controller.rb', line 35

def strategy_status(strategy, feature)
  cache(strategy, feature) do
    status_to_s(strategy.enabled?(feature.key))
  end
end

#switch_url(strategy, feature) ⇒ Object



41
42
43
# File 'app/controllers/flipflop/features_controller.rb', line 41

def switch_url(strategy, feature)
  feature_strategy_path(feature.key, strategy.key)
end