Module: ActsAsEncrypted::Acts::Encrypted::InstanceMethods

Defined in:
lib/acts_as_encrypted.rb

Overview

Istance methods

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(aClass) ⇒ Object

doing this our target class acquires all the methods inside ClassMethods module as class methods.



43
44
45
# File 'lib/acts_as_encrypted.rb', line 43

def self.included(aClass)
  aClass.extend ClassMethods
end

Instance Method Details

#decrypt_field(field) ⇒ Object



60
61
62
63
# File 'lib/acts_as_encrypted.rb', line 60

def decrypt_field(field)
    mark_as_decrypted(field)
    EncryptionWrapper.new(field).decrypt_field(self)
end

#field_is_encrypted?(field) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
50
# File 'lib/acts_as_encrypted.rb', line 47

def field_is_encrypted?(field)
  @encryption_initializer ||= OpenStruct.new
  @encryption_initializer.send(field).nil?
end

#mark_as_decrypted(field) ⇒ Object



56
57
58
# File 'lib/acts_as_encrypted.rb', line 56

def mark_as_decrypted(field)
   @encryption_initializer.send(field + '=', true)
end

#mark_as_encrypted(field) ⇒ Object



52
53
54
# File 'lib/acts_as_encrypted.rb', line 52

def mark_as_encrypted(field)
  @encryption_initializer.send(field + '=', nil)
end