Class: Creds
- Inherits:
-
Object
show all
- Includes:
- Singleton
- Defined in:
- lib/creds.rb,
lib/creds/errors.rb,
lib/creds/version.rb
Overview
The main module of rails-creds
Defined Under Namespace
Classes: MissingCredentialsWarning, MissingEnvError, MissingKeyError, MissingMasterKeyError, NullCredentials
Constant Summary
collapse
- VERSION =
"0.4.0".freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.method_missing(name, *_args) ⇒ Object
29
30
31
32
33
|
# File 'lib/creds.rb', line 29
def self.method_missing(name, *_args)
instance.credentials.fetch(name)
rescue KeyError
raise MissingKeyError.new(name, Rails.env)
end
|
.respond_to_missing?(_name) ⇒ Boolean
25
26
27
|
# File 'lib/creds.rb', line 25
def self.respond_to_missing?(_name)
true
end
|
.to_h ⇒ Object
35
36
37
|
# File 'lib/creds.rb', line 35
def self.to_h
instance.credentials
end
|
Instance Method Details
#credentials ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/creds.rb', line 39
def credentials
return @credentials if @credentials
if dummy?
@credentials = NullCredentials.new
return @credentials
end
unless encrypted_credentials_exist?
Rails.logger.warn(MissingCredentialsWarning)
@credentials = NullCredentials.new
return @credentials
end
raise MissingMasterKeyError unless master_key_present?
@credentials = fetch_credentials_for_current_env
end
|