Sha256: d000a04555a51b069cb11ea6870ae5a4a3a63f7f635c6eb84c8ebdd3a8212bd9

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 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 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)
            controller_action.build_view(error_handler, errors: [e])
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aldous-1.0.1 lib/aldous/controller/action/wrapper.rb