Class: TheGrid::Api::Command::BatchRemove
Instance Method Summary
collapse
#batch?, build, #contextualize, #execute_on, find, register_lookup_scope, scopes
Instance Method Details
3
4
5
6
7
8
|
# File 'lib/the_grid/api/command/batch_remove.rb', line 3
def configure(relation, params)
{}.tap do |o|
o[:item_ids] = params.fetch(:item_ids, []).reject{ |id| id.to_i <= 0 }
raise ArgumentError, "There is nothing to remove" if o[:item_ids].blank?
end
end
|
#run_on(relation, params) ⇒ Object
10
11
12
|
# File 'lib/the_grid/api/command/batch_remove.rb', line 10
def run_on(relation, params)
relation.where(relation.scoped.table.primary_key.in(params[:item_ids])).destroy_all
end
|