Module: BetterController::Base
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/better_controller/base.rb
Overview
Base module that provides core functionality for enhanced controllers
Instance Method Summary collapse
-
#better_controller_handle_error(exception) ⇒ Object
Handle exceptions raised by the controller.
-
#execute_action ⇒ Object
Execute an action with enhanced error handling and response formatting.
-
#with_transaction(options = {}) ⇒ Object
Helper method to simplify common controller patterns.
Instance Method Details
#better_controller_handle_error(exception) ⇒ Object
Handle exceptions raised by the controller
42 43 44 |
# File 'lib/better_controller/base.rb', line 42 def better_controller_handle_error(exception) handle_exception(exception) end |
#execute_action ⇒ Object
Execute an action with enhanced error handling and response formatting
23 24 25 26 27 28 29 |
# File 'lib/better_controller/base.rb', line 23 def execute_action(&) log_debug("Executing action: #{action_name}") if respond_to?(:action_name) result = instance_eval(&) respond_with_success(result) rescue StandardError => e handle_exception(e) end |
#with_transaction(options = {}) ⇒ Object
Helper method to simplify common controller patterns
34 35 36 37 38 |
# File 'lib/better_controller/base.rb', line 34 def with_transaction( = {}, &) ActiveRecord::Base.transaction(&) rescue StandardError => e handle_exception(e, ) end |