Sha256: 82fd50efe36609efbd4a439108e818e56d5a2bbae138f6ec23007972531638c7

Contents?: true

Size: 920 Bytes

Versions: 16

Compression:

Stored size: 920 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)
        return false unless context.actors?

        context.values.groups.any? do |name|
          context.actors.any? do |actor|
            Flipper.group(name).match?(actor, 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

16 entries across 16 versions & 1 rubygems

Version Path
flipper-1.3.2 lib/flipper/gates/group.rb
flipper-1.3.1 lib/flipper/gates/group.rb
flipper-1.3.0 lib/flipper/gates/group.rb
flipper-1.3.0.pre lib/flipper/gates/group.rb
flipper-1.2.2 lib/flipper/gates/group.rb
flipper-1.2.1 lib/flipper/gates/group.rb
flipper-1.2.0 lib/flipper/gates/group.rb
flipper-1.1.2 lib/flipper/gates/group.rb
flipper-1.1.1 lib/flipper/gates/group.rb
flipper-1.1.0 lib/flipper/gates/group.rb
flipper-1.0.0 lib/flipper/gates/group.rb
flipper-1.0.0.pre lib/flipper/gates/group.rb
flipper-0.28.3 lib/flipper/gates/group.rb
flipper-0.28.2 lib/flipper/gates/group.rb
flipper-0.28.1 lib/flipper/gates/group.rb
flipper-0.28.0 lib/flipper/gates/group.rb