Module: FeatureGuard::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/feature_guard/controller.rb

Overview

Mixed into ActionController::Base by the Railtie. It provides the feature class method for declaring protected features and module_enabled? for checking those features in controller actions and views.

Instance Method Summary collapse

Instance Method Details

#module_enabled?(feature_name) ⇒ Boolean

Returns whether a feature is enabled for the current account. Results are cached for the current controller instance, which lasts one request.

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
50
# File 'lib/feature_guard/controller.rb', line 42

def module_enabled?(feature_name)
  feature_name = feature_name.to_sym

  @module_availability_cache ||= {}

  return @module_availability_cache[feature_name] if @module_availability_cache.key?(feature_name)

  @module_availability_cache[feature_name] = resolve_module(feature_name)
end