Class: ActiveRecordAnonymizer::Encryptor

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record_anonymizer/encryptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, attributes) ⇒ Encryptor

Returns a new instance of Encryptor.



7
8
9
10
# File 'lib/active_record_anonymizer/encryptor.rb', line 7

def initialize(model, attributes)
  @model = model
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/active_record_anonymizer/encryptor.rb', line 5

def attributes
  @attributes
end

Instance Method Details

#encryptObject



12
13
14
15
16
17
18
19
# File 'lib/active_record_anonymizer/encryptor.rb', line 12

def encrypt
  if !rails_version_supported?
    raise ActiveRecordAnonymizer::UnsupportedVersionError,
          "ActiveRecordAnonymizer relies on Rails 7+ for encrypted columns."
  end

  @model.encrypts(*@attributes)
end