Class: Workflowable::Workflow

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/workflowable/workflow.rb

Instance Method Summary collapse

Instance Method Details

#run_workflow_actions(options = {}, object, current_stage, next_stage, user) ⇒ Object



32
33
34
35
36
# File 'app/models/workflowable/workflow.rb', line 32

def run_workflow_actions(options={}, object, current_stage, next_stage, user)
    actions.each do |action|
        action.run(options.try(:[],action.name), self, object, current_stage, next_stage, user)
    end
end

#validate_action_options(options = {}, object, current_stage, next_stage, user) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'app/models/workflowable/workflow.rb', line 47

def validate_action_options(options={}, object, current_stage, next_stage, user)
    options ||= {}
    action_errors = {}
    actions.each do |action|
        errors = action.validate_options(options[action.name] || {}, self, object, current_stage, next_stage, user)
        action_errors[action.name] = errors if errors.present?
    end
    action_errors
end

#workflow_action_options(options = {}, object, current_stage, next_stage, user) ⇒ Object



38
39
40
41
42
43
44
45
# File 'app/models/workflowable/workflow.rb', line 38

def workflow_action_options(options={}, object, current_stage, next_stage, user)
    options ||= {}
    workflow_action_options = {}
    actions.each do |action|
        workflow_action_options[action.name] = action.available_options(options.try(:[],action.name) || {}, self, object, current_stage, next_stage, user)
    end
    workflow_action_options
end