Class: BlueprintConfig::Backend::Credentials

Inherits:
Base
  • Object
show all
Defined in:
lib/blueprint_config/backend/credentials.rb

Instance Method Summary collapse

Methods inherited from Base

#fresh?, #nest_hash

Instance Method Details

#load_keysObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/blueprint_config/backend/credentials.rb', line 8

def load_keys
  if defined?(Rails)
    # When Rails is available, use Rails.application.credentials
    # Rails already handles merging global and environment-specific credentials
    Rails.application.credentials.to_h
  else
    # Standalone mode - just load global credentials
    standalone_credentials.to_h
  end
end

#sourceObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/blueprint_config/backend/credentials.rb', line 19

def source
  if defined?(Rails) && Rails.env
    # Check if environment-specific credentials exist
    env_path = "config/credentials/#{Rails.env}.yml.enc"
    if File.exist?(env_path)
      "#{self.class.name}(global + #{Rails.env})"
    else
      "#{self.class.name}(global)"
    end
  else
    "#{self.class.name}"
  end
end