Class: Flipflop::FeaturesController::FeaturesPresenter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(feature_set) ⇒ FeaturesPresenter

Returns a new instance of FeaturesPresenter.



21
22
23
24
25
26
27
28
29
# File 'app/controllers/flipflop/features_controller.rb', line 21

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

  @strategies = @feature_set.strategies.reject(&:hidden?)
  @grouped_features = @feature_set.features.group_by(&:group)

  @application_name = Rails.application.class.parent_name.underscore.titleize
end

Instance Attribute Details

#application_nameObject (readonly)

Returns the value of attribute application_name.



19
20
21
# File 'app/controllers/flipflop/features_controller.rb', line 19

def application_name
  @application_name
end

#grouped_featuresObject (readonly)

Returns the value of attribute grouped_features.



19
20
21
# File 'app/controllers/flipflop/features_controller.rb', line 19

def grouped_features
  @grouped_features
end

#strategiesObject (readonly)

Returns the value of attribute strategies.



19
20
21
# File 'app/controllers/flipflop/features_controller.rb', line 19

def strategies
  @strategies
end

Instance Method Details

#grouped?Boolean

Returns:

  • (Boolean)


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

def grouped?
  grouped_features.keys != [nil]
end

#status(feature) ⇒ Object



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

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

#strategy_status(strategy, feature) ⇒ Object



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

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

#switch_url(strategy, feature) ⇒ Object



47
48
49
# File 'app/controllers/flipflop/features_controller.rb', line 47

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