Class: LcpRuby::Workflow::Approval::CleanupHandler
- Inherits:
-
Object
- Object
- LcpRuby::Workflow::Approval::CleanupHandler
- Defined in:
- lib/lcp_ruby/workflow/approval/cleanup_handler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(context) ⇒ CleanupHandler
constructor
A new instance of CleanupHandler.
Constructor Details
#initialize(context) ⇒ CleanupHandler
Returns a new instance of CleanupHandler.
13 14 15 |
# File 'lib/lcp_ruby/workflow/approval/cleanup_handler.rb', line 13 def initialize(context) @context = context end |
Class Method Details
.async? ⇒ Boolean
9 10 11 |
# File 'lib/lcp_ruby/workflow/approval/cleanup_handler.rb', line 9 def self.async? false end |
.handles_event ⇒ Object
5 6 7 |
# File 'lib/lcp_ruby/workflow/approval/cleanup_handler.rb', line 5 def self.handles_event "_approval_cleanup" end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/lcp_ruby/workflow/approval/cleanup_handler.rb', line 17 def call record = @context[:record] changes = @context[:changes] || {} workflow_def = record.workflow_definition return unless workflow_def&.has_approvals? # Determine which state we just left field = workflow_def.field old_state = changes.dig(field, 0) return unless old_state approval_def = workflow_def.approval_for(old_state) return unless approval_def Engine.cancel(record, workflow_def, old_state) end |