class LdapQuery::RailsCredentials
If used with a rails application, this allows the the script to pull ldap credentials from Rails.application.credentials
Attributes
credentials[RW]
Public Class Methods
credentials()
click to toggle source
Used to grab the applications encrypted credentials with the ldap key
@return [Hash]
# File lib/ldap_query/rails_credentials.rb, line 11 def self.credentials return EMPTY_HASH unless rails? @_credentials ||= Rails.application.credentials[:ldap] rescue # In case an older rails application is used were `Rails.application.credentials` isn't defined raise(CredentialsError, 'Rails.application.credentials could not be found') end
rails?()
click to toggle source
Used to verify `Rails.application` exists within the codebase
@return [Boolean]
# File lib/ldap_query/rails_credentials.rb, line 23 def self.rails? (defined?(Rails) && Rails.respond_to?(:application)) end