File: verify_result_attribute.rb

package info (click to toggle)
ruby-mail-gpg 0.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 328 kB
  • sloc: ruby: 2,289; makefile: 6
file content (31 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
module Mail
  module Gpg
    module VerifyResultAttribute

      # the result of signature verification, as provided by GPGME
      def verify_result(result = nil)
        if result
          self.verify_result = result
        else
          @verify_result
        end
      end
      def verify_result=(result)
        @verify_result = result
      end

      # checks validity of signatures (true / false)
      def signature_valid?
        sigs = self.signatures
        sigs.any? && sigs.all?{|s|s.valid?}
      end

      # list of all signatures from verify_result
      def signatures
        [verify_result].flatten.compact.map do |vr|
          vr.signatures
        end.flatten.compact
      end
    end
  end
end