module Shamu::Features::Support

Add feature togggle support to an object.

Private Instance Methods

feature_enabled?( feature ) click to toggle source

@!visibility public

Determines if the given feature has been toggled.

@param [Symbol] feature name of the feature to check. @return [Boolean] true if the feature has been toggled on.

# File lib/shamu/features/support.rb, line 46
def feature_enabled?( feature )
  features_service.enabled?( feature )
end
when_feature( feature, override: nil ) { || ... } click to toggle source

@!visibility public

Only execute the block if the current {Features::Context} has the named featue enabled.

@param [String] feature name. @param [Boolean] override force the feature to be either on or off. @yield Yields if the feature is enabled. @yieldreturn the result of the block or nil if the feature wasn't

enabled.
# File lib/shamu/features/support.rb, line 36
def when_feature( feature, override: nil, &block )
  yield if override.nil? ? feature_enabled?( feature ) : override
end