Reset source_workflow_instance on condition

This commit is contained in:
ari 2022-08-10 14:18:54 +03:00
parent fe0af4cd33
commit 7523e0b719
No known key found for this signature in database
GPG Key ID: 1A5559E2E32F1805

View File

@ -48,11 +48,11 @@ module Workflower
@allowed_transitions ||= @workflower_base.allowed_transitions @allowed_transitions ||= @workflower_base.allowed_transitions
end end
def workflower_uninitializer def workflower_uninitializer(reset_source_workflow_instance: false)
@workflower_base.uninitialize @workflower_base.uninitialize
@workflower_base = nil @workflower_base = nil
@source_workflow_instance = nil @source_workflow_instance = nil if reset_source_workflow_instance
@possible_events = nil @possible_events = nil
@allowed_events = nil @allowed_events = nil
@allowed_transitions = nil @allowed_transitions = nil
@ -83,9 +83,9 @@ module Workflower
end end
def workflower_abilities(workflow_selector: nil) def workflower_abilities(workflow_selector: nil)
# workflow_selector helps dynamic transition selection when we have multiple workflows that needs to change depending on the selector. # workflow_selector helps dynamic transition selection when we have multiple workflows that needs to change depending on the workflow_selector.
load = source.new(new).get_workflows.values.flatten.uniq unless workflow_selector.present? load = source.new(new).get_workflows.values.flatten.uniq unless workflow_selector.present?
load = source.new(selector.to_sym).get_workflows.values.flatten.uniq if selector.present? load = source.new(workflow_selector.to_sym).get_workflows.values.flatten.uniq if workflow_selector.present?
unless load.blank? unless load.blank?
# transitions = load.transitions.where("(metadata->>'roles') IS NOT NULL") # transitions = load.transitions.where("(metadata->>'roles') IS NOT NULL")