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

#save(*args) ⇒ Object



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

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

#with_constraints_handling(action) ⇒ Object



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

def with_constraints_handling action
  begin
    yield
  rescue ActiveRecord::InvalidForeignKey, ActiveRecord::StatementInvalid => e
    if Handlers.handler( e )
      Handlers.handle( action, e, self )
    else
      raise
    end
  end
end