Sha256: c3d43848f48db2bb94977e571027b5efd56315f5ba0eecf4b1d2ab1f084a52f9
Contents?: true
Size: 876 Bytes
Versions: 22
Compression:
Stored size: 876 Bytes
Contents
module Katello class BulkItemsHelper attr_reader :bulk_params, :model_scope, :key def initialize(bulk_params:, model_scope:, key: :id) @bulk_params = bulk_params if @bulk_params.is_a?(String) @bulk_params = ActiveSupport::JSON.decode(@bulk_params). deep_symbolize_keys end @model_scope = model_scope @key = key end def fetch params = bulk_params params[:included] ||= {} params[:excluded] ||= {} items = model_scope if params[:included][:ids] items = model_scope.where(key => params[:included][:ids]) elsif params[:included][:search] items = model_scope.search_for(params[:included][:search]) end if params[:excluded][:ids] items = items.where.not(key => params[:excluded][:ids]) end items end end end
Version data entries
22 entries across 22 versions & 1 rubygems