Sha256: 37562642c5c07e84f31c54a986b781a98ca470d73f9ae394a0f011675c341615
Contents?: true
Size: 678 Bytes
Versions: 19
Compression:
Stored size: 678 Bytes
Contents
class BMC::CollectionUpdate extend AttrExtras.mixin attr_reader_initialize :scope, :params_array def self.call(...) new(...).call end def call return update end def update! ApplicationRecord.transaction do params_array.each do |object_param| if object_param[:id].present? object = scope.find(object_param[:id]) else object = scope.new end if object_param.delete(:_destroy).to_i == 1 object.destroy! else object.update!(object_param) end end end true end def update update! rescue ActiveRecord::RecordInvalid false end end
Version data entries
19 entries across 19 versions & 1 rubygems