Module: ROM::Plugins::Schema::EncryptedAttributes
- Defined in:
- lib/rom/plugins/schema/encrypted_attributes.rb
Defined Under Namespace
Modules: DSL
Class Method Summary collapse
Class Method Details
.apply(schema, **options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rom/plugins/schema/encrypted_attributes.rb', line 9 def self.apply(schema, **) attributes = .fetch(:attributes) primary_key = .fetch(:primary_key, ROM::EncryptedAttribute.config.primary_key) key_derivation_salt = .fetch(:key_derivation_salt, ROM::EncryptedAttribute.config.key_derivation_salt) hash_digest_class = .fetch(:hash_digest_class, ROM::EncryptedAttribute.config.hash_digest_class) encrypted_string, encrypted_string_reader = ROM::EncryptedAttribute.define_encrypted_attribute_types( primary_key: primary_key, key_derivation_salt: key_derivation_salt, hash_digest_class: hash_digest_class ) attrs = attributes.map do |name| ROM::Schema::DSL.new(schema.name).build_attribute_info( name, encrypted_string, name: name, read: encrypted_string_reader ) end schema.attributes.concat( schema.class.attributes(attrs, schema.attr_class) ) end |