Class: InlineEncryption::Config
- Inherits:
-
Hash
- Object
- Hash
- InlineEncryption::Config
- Includes:
- Hashie::Extensions::IndifferentAccess, Hashie::Extensions::MethodAccess
- Defined in:
- lib/inline_encryption/config.rb
Overview
known configuration variables key - a String containing the private key, a filename pointing to the private key, or an OpenSSL::PKey::RSA
Instance Method Summary collapse
-
#check_required_variables ⇒ Object
checks required, currently only the ‘key’.
-
#real_key ⇒ OpenSSL::PKey::RSA
The OpenSSL key instance.
Instance Method Details
#check_required_variables ⇒ Object
checks required, currently only the ‘key’
17 18 19 |
# 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 ⇒ OpenSSL::PKey::RSA
Returns the OpenSSL key instance.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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 |