aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/concerns/control_flow.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/concerns/control_flow.rb')
-rw-r--r--app/controllers/concerns/control_flow.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/concerns/control_flow.rb b/app/controllers/concerns/control_flow.rb
new file mode 100644
index 000000000..0f41a1cda
--- /dev/null
+++ b/app/controllers/concerns/control_flow.rb
@@ -0,0 +1,14 @@
+module ControlFlow
+ FinishAction = Class.new RuntimeError
+
+ def self.included into
+ into.rescue_from FinishAction, with: :catch_finish_action
+ end
+
+ # Allow to exit locally inside an action after rendering (especially in error cases)
+ def catch_finish_action; end
+
+ def finish_action! msg = 'finish action'
+ raise FinishAction, msg
+ end
+end