class Aldous::Controller::PreconditionsExecutionService

Attributes

action_wrapper[R]
controller[R]

Public Class Methods

new(action_wrapper, controller) click to toggle source
# File lib/aldous/controller/preconditions_execution_service.rb, line 9
def initialize(action_wrapper, controller)
  @action_wrapper = action_wrapper
  @controller = controller
end

Public Instance Methods

perform() click to toggle source
# File lib/aldous/controller/preconditions_execution_service.rb, line 14
def perform
  if action_wrapper.respond_to?(:preconditions) && !action_wrapper.preconditions.empty?
    action_wrapper.preconditions.each do |precondition_class|
      action = action_wrapper.controller_action
      precondition = precondition_class.build(action, controller, action.view_builder)
      precondition_result = precondition.perform

      if precondition_result.kind_of?(::Aldous::Respondable::Base)
        return [precondition, precondition_result]
      end
    end
  end
  [nil, nil]
end