Sha256: 74a43bfc8f894169b3a1f92fee1ab7ca8ee974f0e8fe4a344ef5801ef1d69bfb

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true

module EJSON
  module Rails
    Rails = ::Rails
    private_constant :Rails

    class Railtie < Rails::Railtie
      initializer "ejson-rails.merge_secrets" do
        json_files.each do |file|
          next unless valid?(file)
          secrets = JSON.parse(file.read, symbolize_names: true)
          break Rails.application.secrets.deep_merge!(secrets)
        end
      end

      private

      def valid?(pathname)
        pathname.exist?
      end

      def json_files
        [
          Rails.root.join("config", "secrets.json"),
          Rails.root.join("config", "secrets.#{Rails.env}.json"),
        ]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ejson-rails-0.1.0 lib/ejson/rails/railtie.rb