Sha256: f192489710be9d6f0b7de9ab1b1d9a497b621e3d47ffb1088d14ae20551dfaef
Contents?: true
Size: 1.28 KB
Versions: 17
Compression:
Stored size: 1.28 KB
Contents
module Shamu module Features # A selector used to match conditions against environment configuration. class Selector # ============================================================================ # @!group Attributes # # @!attribute # @return [Array<Condition>] conditions that must match for the selector # to match. attr_reader :conditions # @!attribute # @return [Boolean] true if the feature should not be enabled when the # selector matches. attr_reader :reject # @!attribute # @return [Toggle] that owns the selector. attr_reader :toggle # # @!endgroup Attributes def initialize( toggle, config ) @conditions = [] config.each do |name, condition_config| if name == "reject" @reject = condition_config.to_bool else @conditions << Conditions::Condition.create( name, condition_config, toggle ) end end @conditions.freeze end # @param [Context] context the feature evaluation context. # @return [Boolean] true if the selector matches the given environment. def match?( context ) conditions.all? { |c| c.match?( context ) } end end end end
Version data entries
17 entries across 17 versions & 1 rubygems