Module: Unconstrained::Handlers
- Defined in:
- lib/unconstrained/handlers.rb,
lib/unconstrained/handlers/postgresql.rb,
lib/unconstrained/handlers/abstract_handler.rb
Defined Under Namespace
Classes: AbstractHandler, PostgreSQLFKHandler
Class Method Summary
collapse
Class Method Details
.handle(action, exception, record) ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/unconstrained/handlers.rb', line 11
def handle action, exception, record
h = handler(exception).new(exception.message, record)
case action
when :destroy
h.handle_destroy
when :save
h.handle_save
end
end
|
.handler(exception) ⇒ Object
8
9
10
|
# File 'lib/unconstrained/handlers.rb', line 8
def handler exception
@handlers.detect { |k, _| exception.message.start_with?(k) }&.last
end
|
.register(exception_name, handler) ⇒ Object
5
6
7
|
# File 'lib/unconstrained/handlers.rb', line 5
def register exception_name, handler
@handlers[exception_name] = handler
end
|