Module: Uncouple::ActionPerformer
- Defined in:
- lib/uncouple/action_performer.rb
Instance Method Summary collapse
- #params_with_current_user(params) ⇒ Object
- #perform(action_class, action_params = nil, &block) ⇒ Object
Instance Method Details
#params_with_current_user(params) ⇒ Object
14 15 16 17 |
# 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) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# 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. block.call if block_given? && @action.success? end @action end |