module Uncouple::ActionPerformer

Public Instance Methods

params_with_current_user(params) click to toggle source
# File lib/uncouple/action_performer.rb, line 14
def params_with_current_user(params)
  return params if params.nil? || !respond_to?(:current_user)
  params.merge(current_user: current_user)
end
perform(action_class, action_params=nil, &block) click to toggle source
# File lib/uncouple/action_performer.rb, line 4
def perform(action_class, action_params=nil, &block)
  action_params ||= params if respond_to?(:params)
  action_params = params_with_current_user(action_params)
  if @action = action_class.new(action_params)
    @action.perform_with_authorization
    block.call if block_given? && @action.success?
  end
  @action
end