Sha256: 168057a3d865e1436da145331c4bfc3f5d464e6e1966a0f652bbde0417d7c16a
Contents?: true
Size: 903 Bytes
Versions: 49
Compression:
Stored size: 903 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].present? items = model_scope.where(key => params[:included][:ids]) elsif params[:included][:search].present? items = model_scope.search_for(params[:included][:search]) end if params[:excluded][:ids].present? items = items.where.not(key => params[:excluded][:ids]) end items end end end
Version data entries
49 entries across 49 versions & 1 rubygems