Sha256: 032410991b80f54a3cc75068440d5e9baf15e55f25af3038a020fa4b87f8d290
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'interactor' module DiscoApp module Flow class ProcessAction include Interactor delegate :action, to: :context delegate :action_service_class, to: :context def call validate_action find_action_service_class execute_action_service_class end private def validate_action context.fail! unless action.pending? end def find_action_service_class context.action_service_class = action.action_id.classify.safe_constantize || %Q(Flow::Actions::#{("#{action.action_id}".classify)}).safe_constantize if action_service_class.nil? update_action(false, ["Could not find service class for #{action.action_id}"]) context.fail! end end def execute_action_service_class result = action_service_class.call(shop: action.shop, properties: action.properties) update_action(result.success?, result.errors) end def update_action(success, errors) action.update!( status: success ? Action.statuses[:succeeded] : Action.statuses[:failed], processing_errors: success ? [] : errors, processed_at: Time.current ) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release | app/services/disco_app/flow/process_action.rb |
disco_app-0.16.1 | app/services/disco_app/flow/process_action.rb |