Override IssueObserver method
Added by Ann Buyanova over 15 years ago
Hi.
Is it possible?
I know that overriding model methods is not very good, but I need another behavior of observer in my plugin.
Replies (3)
RE: Override IssueObserver method - Added by Eric Davis about 15 years ago
It's possible, I've done it in some private code. Do you need to add another observer or override the existing method?
Eric Davis
RE: Override IssueObserver method - Added by Ann Buyanova about 15 years ago
I needed to override an existing method. I tried but didn't succeed.
Now I had to switch to stable redmine release and there is no IssueObserver, so I solved my problem in other way, I think I'll return to this topic later.
RE: Override IssueObserver method - Added by Eric Davis about 15 years ago
Ann Buyanova:
Here's some code I'm using in a private plugin to override the existing IssueObserver. Hope this helps.
# init.rb
require 'dispatcher'
require 'my_issue_observer_patch'
Dispatcher.to_prepare do
IssueObserver.instance.extend(MyIssueObserverPatch)
end
# lib/my_issue_observer_patch.rb
module MyIssueObserverPatch
def after_create(issue)
# Custom method here
end
end
Eric Davis