Sha256: 8793e1247d663c5bfa377345b12333f3e70d5db00f8e58ddf976c865537b0fc9

Contents?: true

Size: 475 Bytes

Versions: 1

Compression:

Stored size: 475 Bytes

Contents

# frozen_string_literal: true

module TPRecordOptimistic
  require 'tp_record_optimistic/engine' if defined?(Rails)
  extend ActiveSupport::Concern

  # def save(*args)
  #   super(*args)
  # end

  # alias old_save save

  def save(*args)
    super(*args)
  rescue ActiveRecord::RecordNotUnique => e
    errors.add('all', e.to_s)
    return false
  end

  # alias save save_optimistic

  def optimistic_unique; end
end

ActiveRecord::Base.send(:include, TPRecordOptimistic)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tp_record_optimistic-0.0.5 lib/tp_record_optimistic.rb