class Shamu::Features::Conditions::Condition

A condition that must be met for a {Selector} to match and enable a {Toggle}.

Attributes

config[R]
toggle[R]

Public Class Methods

create( name, config, toggle ) click to toggle source

@param [String] name of the condition. @param [Object] config settings for the condition.

# File lib/shamu/features/conditions/condition.rb, line 11
def self.create( name, config, toggle )
  @condition_class ||= Hash.new do |hash, key|
    hash[key] = "Shamu::Features::Conditions::#{ key.to_s.camelize }".constantize
  end

  @condition_class[name].new config, toggle
end
new( config, toggle ) click to toggle source

@param [Object] config options selected for the condition.

# File lib/shamu/features/conditions/condition.rb, line 20
def initialize( config, toggle )
  @config = config
  @toggle = toggle
end

Public Instance Methods

match?( context ) click to toggle source

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

# File lib/shamu/features/conditions/condition.rb, line 27
def match?( context )
  fail NotImplementedError
end