-
Notifications
You must be signed in to change notification settings - Fork 420
Defined methods in an anonymous module #99
Copy link
Copy link
Closed
Description
Would the maintainers be open to a pull request moving the generated methods to either an anonymous or usefully named module similar to state_machine. This would allow for end users to more easily manipulate the execution path on these methods. In my particular instance I'd like to be able to rescue from errors raised in the decryption process and handle them in an application specific manner.
With the current implementation we would have to do something like:
class User
attr_encrypted :email
def email_rescuing_errors
email_raising_errors
rescue AttrEncrypted::Errors::Error
self.email = nil
end
alias_method :email_raising_errors, :email
alias_method :email, :email_rescuing_errors
endBut with a module inserted in the inheritance chain we could simplify things quite a bit:
class User
attr_encrypted :email
def email
super
rescue AttrEncrypted::Errors::Error
self.email = nil
end
endAdditionally I suspect it could simplify the implementation of custom (en|de)cryptors.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels