<commit_before>module Flipper
  module Gates
    class Actor < Gate
      # Internal: The name of the gate. Used for instrumentation, etc.
      def name
        :actor
      end

      # Internal: The piece of the adapter key that is unique to the gate class.
      def key
        :actors
      end

      # Internal: The toggle class used to enable/disable the gate for a thing.
      def toggle_class
        Toggles::Set
      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)
        instrument(:open?, thing) { |payload|
          if thing.nil?
            false
          else
            if Types::Actor.wrappable?(thing)
              actor = Types::Actor.wrap(thing)
              enabled_actor_ids = value
              enabled_actor_ids.include?(actor.value)
            else
              false
            end
          end
        }
      end

      def protects?(thing)
        Types::Actor.wrappable?(thing)
      end

      def enable(thing)
        super Types::Actor.wrap(thing)
      end

      def disable(thing)
        super Types::Actor.wrap(thing)
      end

      def description
        if enabled?
          actor_ids = value.to_a.sort.map { |id| id.inspect }
          "actors (#{actor_ids.join(', ')})"
        else
          'disabled'
        end
      end
    end
  end
end<commit_msg>Remove toggle from actor.<commit_after>module Flipper
  module Gates
    class Actor < Gate
      # Internal: The name of the gate. Used for instrumentation, etc.
      def name
        :actor
      end

      # Internal: The piece of the adapter key that is unique to the gate class.
      def key
        :actors
      end

      def enable(thing)
        thing = Types::Actor.wrap(thing)
        adapter.set_add adapter_key, thing.value
        true
      end

      def disable(thing)
        thing = Types::Actor.wrap(thing)
        adapter.set_delete adapter_key, thing.value
        true
      end

      def enabled?
        !value.empty?
      end

      def value
        adapter.set_members adapter_key
      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)
        instrument(:open?, thing) { |payload|
          if thing.nil?
            false
          else
            if Types::Actor.wrappable?(thing)
              actor = Types::Actor.wrap(thing)
              enabled_actor_ids = value
              enabled_actor_ids.include?(actor.value)
            else
              false
            end
          end
        }
      end

      def protects?(thing)
        Types::Actor.wrappable?(thing)
      end

      def description
        if enabled?
          actor_ids = value.to_a.sort.map { |id| id.inspect }
          "actors (#{actor_ids.join(', ')})"
        else
          'disabled'
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07499163039839303, 'fraction_numerical': 0.0, 'mean_word_length': 1.5151515151515151, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3070853', 'n_tokens_mistral': 830, 'n_tokens_neox': 822, 'n_words': 259}