Sha256: 36962d029360f561e5560f12090ff5305ba8148a395bbbeee2f09d34a27d287b

Contents?: true

Size: 770 Bytes

Versions: 1

Compression:

Stored size: 770 Bytes

Contents

require "redis" unless defined? Redis

require "feature_guard/version"
require "feature_guard/guard"

module FeatureGuard
  class << self
    attr_writer :redis

    def all_flags
      redis.hgetall(flags_hkey).keys.inject({}) { |h, f| h[f] = enabled? f; h }
    end

    def all_ramps
      redis.hgetall(ramps_hkey).keys.inject({}) { |h, f| h[f] = ramp_val f; h }
    end

    def flags_hkey
      "featureguard_flags"
    end

    def ramps_hkey
      "featureguard_ramps"
    end

    def redis
      @redis ||= Redis.new
    end

    [
      :allow?, :bump_ramp, :disable, :enable, :toggle, :enabled?,
      :ramp_val, :set_ramp
    ].each do |mname|
      define_method(mname) do |key, *args|
        Guard.new(key).send(mname, *args)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feature_guard-0.2.1 lib/feature_guard.rb