class InlineEncryption::Config

known configuration variables key - a String containing the private key, a filename pointing to the private key, or an OpenSSL::PKey::RSA

Public Instance Methods

check_required_variables() click to toggle source

checks required, currently only the 'key' @raises [InlineEncryption::MissingRequiredVariableError] raise on a missing variable

# File lib/inline_encryption/config.rb, line 17
def check_required_variables
  raise MissingRequiredVariableError.new(I18n.t('error.missing_key')) unless self.has_key?(:key)
end
real_key() click to toggle source

@return [OpenSSL::PKey::RSA] the OpenSSL key instance

# File lib/inline_encryption/config.rb, line 23
def real_key
  case self[:key]
    when NilClass
      nil
    when String
      if File.exists?(self[:key])
        OpenSSL::PKey::RSA.new(File.read(self[:key]))
      else
        OpenSSL::PKey::RSA.new(self[:key])
      end
    when OpenSSL::PKey::RSA
      self[:key]
  end
end