Zooip/smooth_change

View on GitHub
sig/lib/smooth_change/client_feature_toggler.rbs

Summary

Maintainability
Test Coverage
module SmoothChange
  # Store client features requirements
  class ClientFeatureToggler
    def initialize: (?::Hash[String|Symbol, bool|nil] values) -> void

    def values: () -> ::Hash[Symbol, bool|nil]

    # if true : feature is wanted
    # if false : feature is explicitly not wanted
    # if nil : not specified
    def value_for: (String|Symbol feature) -> (bool|nil)

    def enabled?: (String|Symbol feature_name) -> (bool)

    # Http header is expected to be a comma separated list like :
    #   "feature1, !feature2, feature3"
    # Spaces between elements are ignored
    # A leading "!" means the feature request is opt-out
    def self.from_http_header: (String http_header_value) -> ClientFeatureToggler

    private

    def adapter: () -> Adapters::_Adapter

    # @return [SmoothChange::Feature]
    # @param [String] feature_name
    def find_feature: (String|Symbol feature_name) -> Feature
  end
end