Sha256: 91fec2737b9d3f3c757770f5aa943e8a688cb18e903cba019e23ad9229e11406
Contents?: true
Size: 673 Bytes
Versions: 15
Compression:
Stored size: 673 Bytes
Contents
module Synchronisable class Import < ActiveRecord::Base belongs_to :synchronisable, polymorphic: true serialize :attrs, Hash scope :with_synchronisable_type, ->(type) { where(synchronisable_type: type) } scope :with_synchronisable_ids, ->(ids) { where(synchronisable_id: ids) } scope :with_remote_id, ->(id) { where(remote_id: id.to_s) } scope :with_remote_ids, ->(ids) { where(remote_id: ids.map(&:to_s)) } def self.find_by_remote_id(id) with_remote_id(id).first end def destroy_with_synchronisable ActiveRecord::Base.transaction do synchronisable.try :destroy destroy end end end end
Version data entries
15 entries across 15 versions & 1 rubygems