Sha256: 84b1f17f93000516837fc7c605904a44f7a9cd22caa3c48c8b06dd64007f5c50

Contents?: true

Size: 454 Bytes

Versions: 6

Compression:

Stored size: 454 Bytes

Contents

# frozen_string_literal: true

module Care::AutoFinder
  #
  # Содержит методы для фильтрации по ids
  #
  # @example
  #   class Finder
  #     include ByIds
  #
  #     attr_accessor :params
  #
  #     def call
  #       params = { ids: [1, 2, 3] }
  #       by_ids(Document)
  #     end
  #   end
  #
  module ByIds
    def ids(items)
      params[:ids].present? ? items.where(id: params[:ids]) : items
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
care-0.1.6 lib/care/auto_finder/by_ids.rb
care-0.1.5 lib/care/auto_finder/by_ids.rb
care-0.1.4 lib/care/auto_finder/by_ids.rb
care-0.1.3 lib/care/auto_finder/by_ids.rb
care-0.1.1 lib/care/auto_finder/by_ids.rb
care-0.1.0 lib/care/auto_finder/by_ids.rb