Sha256: 758e8d2115bac0319b242aedef84cc2195f6e9acf62310160fcf5fcd789f112d

Contents?: true

Size: 1.04 KB

Versions: 17

Compression:

Stored size: 1.04 KB

Contents

module Shamu
  module Features
    module Conditions

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

        # @param [String] name of the condition.
        # @param [Object] config settings for the condition.
        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

        # @param [Object] config options selected for the condition.
        def initialize( config, toggle )
          @config = config
          @toggle = toggle
        end

        # @param [Context] context the feature evaluation context.
        # @return [Boolean] true if the condition matches the given environment.
        def match?( context )
          fail NotImplementedError
        end

        private

          attr_reader :config
          attr_reader :toggle
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
shamu-0.0.24 lib/shamu/features/conditions/condition.rb
shamu-0.0.21 lib/shamu/features/conditions/condition.rb
shamu-0.0.20 lib/shamu/features/conditions/condition.rb
shamu-0.0.19 lib/shamu/features/conditions/condition.rb
shamu-0.0.18 lib/shamu/features/conditions/condition.rb
shamu-0.0.17 lib/shamu/features/conditions/condition.rb
shamu-0.0.15 lib/shamu/features/conditions/condition.rb
shamu-0.0.14 lib/shamu/features/conditions/condition.rb
shamu-0.0.13 lib/shamu/features/conditions/condition.rb
shamu-0.0.11 lib/shamu/features/conditions/condition.rb
shamu-0.0.9 lib/shamu/features/conditions/condition.rb
shamu-0.0.8 lib/shamu/features/conditions/condition.rb
shamu-0.0.7 lib/shamu/features/conditions/condition.rb
shamu-0.0.5 lib/shamu/features/conditions/condition.rb
shamu-0.0.4 lib/shamu/features/conditions/condition.rb
shamu-0.0.3 lib/shamu/features/conditions/condition.rb
shamu-0.0.2 lib/shamu/features/conditions/condition.rb