-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allows the definition of a customized whodunnit in a small scope #334
Conversation
def whodunnit(whodunnit) | ||
@whodunnit = whodunnit | ||
yield if block_given? | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this would make more sense instead of having whodunnit
and _whodunnit
def whodunnit(whodunnit = PaperTrail.whodunnit)
@whodunnit = whodunnit
yield if block_given?
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @seanlinsley, what about the case where I don't want to use my_object.whodunnit
?
Did you have plans to merge this? |
@lucasas - Yes. After reviewing the PR a little more closely just now I'm thinking it probably makes more sense to drop the instance variable store and only allow this method to be called with a block argument to prevent confusion. As in: PaperTrail.whodunnit = 'Andy Stewart'
widget = Widget.create!
widget.versions.last.whodunnit # 'Andy Stewart'
# This will work
widget.whodunnit 'Lucas Souza' do
widget.update_attributes :name => 'Wibble'
end
widget.versions.last.whodunnit # 'Lucas Souza'
# This won't
Widget.whodunnit = 'Lucas Souza' # Throws Error I just think trying to store the value as an instance variable could create some confusion both with usage and with code readability in terms of adding an additional level of complexity. Does that make sense? |
Hi @batter, thanks for accept my PR. I think make sense your changes. |
It's very useful when you want to define who is responsible to change some object and don't considering the global scope or request scope.