Class: Sentry::SymmetricSentryCallback
- Inherits:
-
Object
- Object
- Sentry::SymmetricSentryCallback
- Defined in:
- lib/sentry/symmetric_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) ⇒ SymmetricSentryCallback
constructor
A new instance of SymmetricSentryCallback.
Constructor Details
#initialize(attr_name) ⇒ SymmetricSentryCallback
Returns a new instance of SymmetricSentryCallback.
3 4 5 |
# File 'lib/sentry/symmetric_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/symmetric_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/symmetric_sentry_callback.rb', line 8 def before_validation(model) return if model.send(@attr_name).blank? model.send("crypted_#{@attr_name}=", SymmetricSentry.encrypt_to_base64(model.send(@attr_name))) end |