Class: Sentry::AsymmetricSentryCallback
- Inherits:
-
Object
- Object
- Sentry::AsymmetricSentryCallback
- Defined in:
- lib/sentry/asymmetric_sentry_callback.rb
Instance Method Summary collapse
- #after_save(model) ⇒ Object
-
#before_validation(model) ⇒ Object
Performs encryption on before_validation Active Record callback.
-
#initialize(attr_name) ⇒ AsymmetricSentryCallback
constructor
A new instance of AsymmetricSentryCallback.
Constructor Details
#initialize(attr_name) ⇒ AsymmetricSentryCallback
Returns a new instance of AsymmetricSentryCallback.
3 4 5 |
# File 'lib/sentry/asymmetric_sentry_callback.rb', line 3 def initialize(attr_name) @attr_name = attr_name end |
Instance Method Details
#after_save(model) ⇒ Object
13 14 15 |
# File 'lib/sentry/asymmetric_sentry_callback.rb', line 13 def after_save(model) model.send("#{@attr_name}=", nil) end |
#before_validation(model) ⇒ Object
Performs encryption on before_validation Active Record callback
8 9 10 11 |
# File 'lib/sentry/asymmetric_sentry_callback.rb', line 8 def before_validation(model) return if model.send(@attr_name).blank? model.send("crypted_#{@attr_name}=", AsymmetricSentry.encrypt_to_base64(model.send(@attr_name))) end |