gpg_key_subkey.rb 621 Bytes
Newer Older
1
class GpgKeySubkey < ActiveRecord::Base
2 3 4 5 6
  include ShaAttribute

  sha_attribute :keyid
  sha_attribute :fingerprint

7
  belongs_to :gpg_key
8

9 10 11 12 13 14 15 16 17 18 19
  validates :gpg_key_id, presence: true
  validates :fingerprint, :keyid, presence: true, uniqueness: true

  def keyid
    super&.upcase
  end

  def fingerprint
    super&.upcase
  end

20 21 22 23 24 25 26 27 28
  def method_missing(m, *a, &b)
    return super unless gpg_key.respond_to?(m)

    gpg_key.public_send(m, *a, &b) # rubocop:disable GitlabSecurity/PublicSend
  end

  def respond_to_missing?(method, include_private = false)
    gpg_key.respond_to?(method, include_private) || super
  end
29
end