require 'yt/actions/list'
require 'yt/models/request'

module Yt
  module Actions
    module DeleteAll
      include List

    private

      def do_delete_all(params = {})
        where(params).map do |item|
          item.delete
        end.tap { @items = [] }
      end

      def where(params = {})
        list.find_all do |item|
          params.all? do |method, value|
            # TODO: could be symbol etc...
            item.respond_to?(method) && case value
            when Regexp then item.send(method) =~ value
            else item.send(method) == value
            end
          end
        end
      end
    end
  end
end
require 'yt/actions/list'
require 'yt/models/request'

module Yt
  module Actions
    module DeleteAll
      include List

    private

      def do_delete_all(params = {})
        list_all(params).map do |item|
          item.delete
        end.tap { @items = [] }
      end

      def list_all(params = {})
        list.find_all do |item|
          params.all? do |method, value|
            # TODO: could be symbol etc...
            item.respond_to?(method) && case value
            when Regexp then item.send(method) =~ value
            else item.send(method) == value
            end
          end
        end
      end
    end
  end
end
Rename private method `where` to avoid conflicts
Rename private method `where` to avoid conflicts

A public `where` method will be added to Yt::Actions::List in the
next commit, so we can use another less important name for a private method.
