Sha256: 17447c48da3f3cecec53f121e8713513e6f2cce7ee09b463e8661e9d1c11eca8
Contents?: true
Size: 910 Bytes
Versions: 4
Compression:
Stored size: 910 Bytes
Contents
module Flipflop module Configurable attr_accessor :current_group def group(group) self.current_group = GroupDefinition.new(group) yield ensure self.current_group = nil end def feature(feature, **options) options = options.merge(group: current_group) feature = FeatureDefinition.new(feature, **options) FeatureSet.current.add(feature) end def strategy(strategy = nil, **options) if block_given? options[:name] = strategy.to_s options[:lambda] = Proc.new strategy = Strategies::LambdaStrategy end if strategy.kind_of?(Symbol) name = ActiveSupport::Inflector.camelize(strategy) + "Strategy" strategy = Strategies.const_get(name) end if strategy.kind_of?(Class) strategy = strategy.new(**options) end FeatureSet.current.use(strategy) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
flipflop-2.5.0 | lib/flipflop/configurable.rb |
flipflop-2.4.0 | lib/flipflop/configurable.rb |
flipflop-2.3.1 | lib/flipflop/configurable.rb |
flipflop-2.3.0 | lib/flipflop/configurable.rb |