class TheGrid::Api::Command::BatchRemove
Public Instance Methods
configure(relation, params)
click to toggle source
# 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)
click to toggle source
# 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