Module: CryptKeeper::Model
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/crypt_keeper/model.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#ensure_valid_field!(field) ⇒ Object
Public: Ensures that each field exist and is of type text.
Instance Method Details
#ensure_valid_field!(field) ⇒ Object
Public: Ensures that each field exist and is of type text. This prevents encrypted data from being truncated.
10 11 12 13 14 15 16 17 |
# File 'lib/crypt_keeper/model.rb', line 10 def ensure_valid_field!(field) if self.class.columns_hash["#{field}"].nil? raise ArgumentError, "Column :#{field} does not exist" elsif !%i(text binary).include?(self.class.columns_hash["#{field}"].type) raise ArgumentError, "Column :#{field} must be of type 'text' or 'binary' \ to be used for encryption" end end |