Sha256: 94a54558bdc46e7ba323c32a4cbe0ed97831ed6c2075b7404cc0ab063df9c521

Contents?: true

Size: 949 Bytes

Versions: 46

Compression:

Stored size: 949 Bytes

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 enabled?(value)
        !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?(context)
        value = context.values[key]
        if context.thing.nil?
          false
        else
          value.any? do |name|
            group = Flipper.group(name)
            group.match?(context.thing, context)
          end
        end
      end

      def wrap(thing)
        Types::Group.wrap(thing)
      end

      def protects?(thing)
        thing.is_a?(Types::Group) || thing.is_a?(Symbol)
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
flipper-0.20.2 lib/flipper/gates/group.rb
flipper-0.20.1 lib/flipper/gates/group.rb
flipper-0.20.0 lib/flipper/gates/group.rb
flipper-0.20.0.beta3 lib/flipper/gates/group.rb
flipper-0.20.0.beta2 lib/flipper/gates/group.rb
flipper-0.20.0.beta1 lib/flipper/gates/group.rb
flipper-0.19.1 lib/flipper/gates/group.rb
flipper-0.19.0 lib/flipper/gates/group.rb
flipper-0.18.0 lib/flipper/gates/group.rb
flipper-0.17.2 lib/flipper/gates/group.rb
flipper-0.17.1 lib/flipper/gates/group.rb
flipper-0.16.2 lib/flipper/gates/group.rb
flipper-0.16.1 lib/flipper/gates/group.rb
flipper-0.16.0 lib/flipper/gates/group.rb
flipper-0.15.0 lib/flipper/gates/group.rb
flipper-0.14.0 lib/flipper/gates/group.rb
flipper-0.13.0 lib/flipper/gates/group.rb
flipper-0.13.0.beta1 lib/flipper/gates/group.rb
flipper-0.12.2 lib/flipper/gates/group.rb
flipper-0.12.1 lib/flipper/gates/group.rb