-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New observable objects added (Version)
- Loading branch information
Showing
6 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
module RedmineCustomWorkflows | ||
module VersionPatch | ||
|
||
def self.included(base) | ||
base.send(:include, InstanceMethods) | ||
base.class_eval do | ||
before_save :before_save_custom_workflows | ||
after_save :after_save_custom_workflows | ||
before_destroy :before_destroy_custom_workflows | ||
after_destroy :after_destroy_custom_workflows | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
def before_save_custom_workflows | ||
@version = self | ||
@saved_attributes = attributes.dup | ||
CustomWorkflow.run_shared_code(self) | ||
CustomWorkflow.run_custom_workflows(:version, self, :before_save) | ||
errors.empty? && (@saved_attributes == attributes || valid?) | ||
ensure | ||
@saved_attributes = nil | ||
end | ||
|
||
def after_save_custom_workflows | ||
CustomWorkflow.run_custom_workflows(:version, self, :after_save) | ||
end | ||
|
||
def before_destroy_custom_workflows | ||
CustomWorkflow.run_custom_workflows(:version, self, :before_destroy) | ||
end | ||
|
||
def after_destroy_custom_workflows | ||
CustomWorkflow.run_custom_workflows(:version, self, :after_destroy) | ||
end | ||
end | ||
end | ||
end |