Module: Mail::Gpg::MessagePatch

Defined in:
lib/mail/gpg/message_patch.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
# File 'lib/mail/gpg/message_patch.rb', line 7

def self.included(base)
  base.class_eval do
    attr_accessor :raise_encryption_errors
  end
end

Instance Method Details

#decrypt(options = {}) ⇒ Object



58
59
60
# File 'lib/mail/gpg/message_patch.rb', line 58

def decrypt(options = {})
  Mail::Gpg.decrypt(self, options)
end

#encrypted?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/mail/gpg/message_patch.rb', line 54

def encrypted?
  Mail::Gpg.encrypted?(self)
end

#gpg(options = nil) ⇒ Object

turn on gpg encryption / set gpg options.

options are:

encrypt: encrypt the message. defaults to true sign: also sign the message. false by default sign_as: UIDs to sign the message with

See Mail::Gpg methods encrypt and sign for more possible options

mail.gpg encrypt: true mail.gpg encrypt: true, sign: true mail.gpg encrypt: true, sign_as: “[email protected]

future versions will also support sign-only mode: mail.gpg sign_as: ‘[email protected]’, encrypt: false

To turn off gpg encryption use: mail.gpg false



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mail/gpg/message_patch.rb', line 34

def gpg(options = nil)
  case options
  when nil
    @gpg
  when false
    @gpg = nil
    if Mail::Gpg::DeliveryHandler == delivery_handler
      self.delivery_handler = nil
    end
    nil
  end
  if options
    self.raise_encryption_errors = true if raise_encryption_errors.nil?
    @gpg = options
    self.delivery_handler ||= Mail::Gpg::DeliveryHandler
  else
    @gpg
  end
end