class Shamu::Features::Selector

A selector used to match conditions against environment configuration.

Attributes

conditions[R]

@!attribute @return [Array<Condition>] conditions that must match for the selector

to match.
reject[R]

@!attribute @return [Boolean] true if the feature should not be enabled when the

selector matches.
toggle[R]

@!attribute @return [Toggle] that owns the selector.

Public Class Methods

new( toggle, config ) click to toggle source

@!endgroup Attributes

# File lib/shamu/features/selector.rb, line 28
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

Public Instance Methods

match?( context ) click to toggle source

@param [Context] context the feature evaluation context. @return [Boolean] true if the selector matches the given environment.

# File lib/shamu/features/selector.rb, line 44
def match?( context )
  conditions.all? { |c| c.match?( context ) }
end