<commit_before>require_relative '../handler'

module Bra
  module Baps
    module Requests
      module Handlers
        # Handler for playlist
        class Playlist < Handler
          # The handler targets matched by this handler.
          TARGETS = [:playlist]

          # Requests a playlist be DELETEd via the BAPS server
          # 
          # This resets the playlist.
          def delete(object)
            send(Request.new(Codes::Playlist::RESET, object.channel_id))

            false
          end

          # TODO(mattbw): PUT
        end
      end
    end
  end
end<commit_msg>Widen targets for playlist handler.<commit_after>require_relative '../handler'

module Bra
  module Baps
    module Requests
      module Handlers
        # Handler for playlists
        #
        # This handler also targets channels and channel sets, because these
        # all have similar DELETE semantics.
        class Playlist < Handler
          # The handler targets matched by this handler.
          TARGETS = [:playlist, :channel, :channel_set]

          # Requests a playlist be DELETEd via the BAPS server
          # 
          # This resets the playlist.
          def delete(object)
            case object.handler_target 
            when :playlist
              reset(object.channel_id)
            when :channel
              reset(object.id)
            when :channel_set
              object.children.map(&:id).each(&method(:reset))
            end

            false
          end

          # TODO(mattbw): PUT

          private

          # Resets a playlist given its channel ID.
          #
          # @api private
          #
          # @param id [Integer] The ID of the channel to reset.
          #
          # @return [void]
          def reset(id)
            send(Request.new(Codes::Playlist::RESET, id))
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06550449022715267, 'fraction_numerical': 0.0, 'mean_word_length': 1.521970705725699, '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': '3811138', 'n_tokens_mistral': 503, 'n_tokens_neox': 483, 'n_words': 159}