Sha256: 06487de06d9514bdbb73fbed0a3a948eac9d6369d23851a8557b2e61280cb4fa
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
module Flipper module Gates class Group < Gate # Internal: The name of the gate. Used for instrumentation, etc. def name :group end # Internal: Name converted to value safe for adapter. def key :groups end def data_type :set end def description(value) if enabled?(value) group_names = value.to_a.sort.map { |name| name.to_sym.inspect } "groups (#{group_names.join(', ')})" else 'disabled' end end def enabled?(value) !Typecast.to_set(value).empty? end # Internal: Checks if the gate is open for a thing. # # Returns true if gate open for thing, false if not. def open?(thing, value, options = {}) if thing.nil? false else value.any? { |name| begin group = Flipper.group(name) group.match?(thing) rescue GroupNotRegistered false end } end end def protects?(thing) thing.is_a?(Flipper::Types::Group) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flipper-0.7.0.beta2 | lib/flipper/gates/group.rb |
flipper-0.7.0.beta1 | lib/flipper/gates/group.rb |