Sha256: 7622d1f0ac88f944db8ef0d2d50874aad0dad39ae6c48a5db1ea464d826372e5

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'aldous/logging_wrapper'
require 'aldous/respondable/base'

module Aldous
  module Controller
    module Action
      class Wrapper
        attr :controller_action

        def initialize(controller_action)
          @controller_action = controller_action
        end

        def preconditions
          controller_action.preconditions
        end

        def default_view_data
          controller_action.default_view_data
        end

        def default_error_handler(error)
          controller_action.default_error_handler(error)
        end

        def controller
          controller_action.controller
        end

        def view_builder
          controller_action.view_builder
        end

        def perform
          controller_action.perform
        rescue => e
          ::Aldous::LoggingWrapper.log(e)

          error_handler = default_error_handler(e)

          if error_handler.kind_of?(Class) &&
            error_handler.ancestors.include?(Aldous::Respondable::Base)
            view_builder.build(error_handler, errors: [e])
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aldous-1.1.3 lib/aldous/controller/action/wrapper.rb
aldous-1.1.2 lib/aldous/controller/action/wrapper.rb