Sha256: 4dd5430260711b6b25880e184c3d112e03a4a4b59fdf5cad0a71469fa9b6b0cd
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
module Rails module Secrets module InstanceMethods def secrets @secrets ||= ActiveSupport::OrderedOptions.new.tap do |secrets| yaml = config.paths["config/secrets"].first if File.exist?(yaml) require "erb" all_secrets = YAML.load(ERB.new(IO.read(yaml)).result) || {} env_secrets = all_secrets[::Rails.env] secrets.merge!(env_secrets.symbolize_keys) if env_secrets end end end def secrets=(secrets) @secrets = secrets end end class Railtie < ::Rails::Railtie config.before_configuration do |app| app.paths.add "config/secrets", with: "config/secrets.yml" app.extend(InstanceMethods) end config.after_initialize do |app| if app.secrets.secret_key_base.blank? raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`" else app.config.secret_key_base = app.secrets.secret_key_base end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails-secrets-1.0.2 | lib/rails/secrets/railtie.rb |