Class: Workflowable::Stage

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

Instance Method Summary collapse

Instance Method Details

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



58
59
60
61
62
63
# File 'app/models/workflowable/stage.rb', line 58

def run_after_actions(options={}, object, next_stage, user)
    options ||= {}
    self.after_actions.each do |action|
        action.run(options[action.name], self.workflow, object, self, next_stage, user)
    end
end

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



85
86
87
88
89
90
91
92
# File 'app/models/workflowable/stage.rb', line 85

def run_after_options(options={}, object, next_stage, user)
    options ||= {}
    after_action_options = {}
    after_actions.each do |action|
        after_action_options[action.name] = action.available_options(options[action.name] || {}, self.workflow, object, self, next_stage, user)
    end
    after_action_options
end

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



51
52
53
54
55
56
# File 'app/models/workflowable/stage.rb', line 51

def run_before_actions(options={}, object, current_stage, user)
    options ||= {}
    self.before_actions.each do |action|
        action.run(options[action.name], self.workflow, object, current_stage, self, user)
    end
end

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



94
95
96
97
98
99
100
101
# File 'app/models/workflowable/stage.rb', line 94

def run_before_options(options={}, object, current_stage, user)
    options ||= {}
    before_actions_options = {}
    before_actions.each do |action|
        before_actions_options [action.name] = action.available_options(options[action.name] || {}, self.workflow, object, current_stage, self, user)
    end
    before_actions_options
end

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



65
66
67
68
69
70
71
72
73
# File 'app/models/workflowable/stage.rb', line 65

def validate_after_actions(options={}, object, next_stage, user)
    options ||= {}
    after_action_errors = {}
    after_actions.each do |action|
        errors = action.validate_options(options[action.name] || {}, self.workflow, object, self, next_stage, user)
        after_action_errors[action.name] = errors if errors.present?
    end
    after_action_errors
end

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



75
76
77
78
79
80
81
82
83
# File 'app/models/workflowable/stage.rb', line 75

def validate_before_actions(options={}, object, current_stage, user)
    options ||= {}
    before_action_errors = {}
    before_actions.each do |action|
        errors = action.validate_options(options[action.name] || {}, self.workflow, object, current_stage, self, user)
        before_action_errors[action.name] = errors if errors.present?
    end
    before_action_errors
end