Class: LdapQuery::RailsCredentials
- Inherits:
-
Object
- Object
- LdapQuery::RailsCredentials
- Defined in:
- lib/ldap_query/rails_credentials.rb
Overview
If used with a rails application, this allows the the script to pull ldap credentials from Rails.application.credentials
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
Class Method Summary collapse
-
.credentials ⇒ Hash
Used to grab the applications encrypted credentials with the ldap key.
-
.rails? ⇒ Boolean
Used to verify ‘Rails.application` exists within the codebase.
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
6 7 8 |
# File 'lib/ldap_query/rails_credentials.rb', line 6 def credentials @credentials end |
Class Method Details
.credentials ⇒ Hash
Used to grab the applications encrypted credentials with the ldap key
11 12 13 14 15 16 17 18 |
# 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? ⇒ Boolean
Used to verify ‘Rails.application` exists within the codebase
23 24 25 |
# File 'lib/ldap_query/rails_credentials.rb', line 23 def self.rails? (defined?(Rails) && Rails.respond_to?(:application)) end |