I'm working on a gem that would generate notifications based on event triggers. For Example, in a CMS, if an article is created, a notification "Article x created by user y" would be generated. (like Github/Facebook notifications).
In my gem, I have a has_notifications method which when specified in a model, registers callbacks.
The problem, of course is, when the callback is triggered, a corresponding action within the gem is invoked, but this action would require the user id of the user who performed the action to generate the notification.
I've looked towards acts_as_audited and paper_trail for inspiration but both use the Thread.current variable to store the user information, which of course I believe is hacky and not safe.
In terms of basic design, am I doing it right ? What other options do I have, to capture user information from my gem? Should I instead, setup around filters in the respective controllers to create notifications, which in case would use the vanilla current_user method?
Any ideas would be appreciated. Thanks.
Update
I'm looking at using virtual attributes for models with notification call-backs and setting them in the appropriate controllers using before filters.