module HandlePermanentRecordsDestroyedInHasOneAssociation
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/CyclomaticComplexity Support destroy for rails 5.2. has_on associations.
Public Instance Methods
delete(method = options[:dependent])
click to toggle source
# File lib/permanent_records/active_record_5_2.rb, line 21 def delete(method = options[:dependent]) return unless load_target case method when :delete target.delete when :destroy target.destroyed_by_association = reflection target.destroy throw(:abort) if target.respond_to?(:deleted?) && !target.deleted? when :nullify target.update_columns(reflection.foreign_key => nil) if target.persisted? end end