Sha256: 8d7a608f4db496179d345ba8d7251d138c105807f8750cdf6577a7e828f31ba4
Contents?: true
Size: 764 Bytes
Versions: 11
Compression:
Stored size: 764 Bytes
Contents
module DiscoApp::Concerns::Synchronises extend ActiveSupport::Concern class_methods do def should_synchronise?(shop, data) true end def synchronise(shop, data) data = data.with_indifferent_access return unless should_synchronise?(shop, data) instance = self.find_or_create_by!(id: data[:id]) do |instance| instance.shop = shop instance.data = data end instance.update(data: data) instance end def should_synchronise_deletion?(shop, data) true end def synchronise_deletion(shop, data) data = data.with_indifferent_access return unless should_synchronise_deletion?(shop, data) self.destroy_all(shop: shop, id: data[:id]) end end end
Version data entries
11 entries across 11 versions & 1 rubygems