Module: Unconstrained::ActiveRecordPlugin

Defined in:
lib/unconstrained/active_record_plugin.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



9
10
11
12
13
# File 'lib/unconstrained/active_record_plugin.rb', line 9

def destroy
  with_constraints_handling :destroy do
    super
  end
end

#saveObject



3
4
5
6
7
# File 'lib/unconstrained/active_record_plugin.rb', line 3

def save(**)
  with_constraints_handling :save do
    super
  end
end

#with_constraints_handling(action) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/unconstrained/active_record_plugin.rb', line 15

def with_constraints_handling(action)
  yield
rescue ActiveRecord::InvalidForeignKey, ActiveRecord::StatementInvalid => e
  raise unless Handlers.handler(e)

  Handlers.handle(action, e, self)
end