Sha256: 9df2f9a02f0f8aa4c6a122c601bcf87f7c75bff4d60e9f3f714ce5c5f059a0b5

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

# encoding: utf-8
module Symmetric #:nodoc:
  class Railtie < Rails::Railtie #:nodoc:

    # Exposes Symmetric Encryption's configuration to the Rails application configuration.
    #
    # @example Set up configuration in the Rails app.
    #   module MyApplication
    #     class Application < Rails::Application
    #       config.symmetric_encryption.cipher = 'aes-256-cbc'
    #     end
    #   end
    #config.symmetric_encryption = ::Symmetric::Config

    rake_tasks do
      load "symmetric/railties/symmetric_encryption.rake"
    end

    # Initialize Symmetry. This will look for a symmetry.yml in the config
    # directory and configure Symmetry appropriately.
    #
    # @example symmetry.yml
    #
    #   development:
    #     cipher: aes-256-cbc
    #     symmetric_key: 1234567890ABCDEF1234567890ABCDEF
    #     symmetric_iv: 1234567890ABCDEF
    #
    initializer "load symmetry encryption keys" do
      config.before_initialize do
        config_file = Rails.root.join("config", "symmetric-encryption.yml")
        if config_file.file?
          ::Symmetric::Encryption.load!(config_file, Rails.env)
        else
          puts "\nSymmetric Encryption config not found. Create a config file at: config/symmetric-encryption.yml"
          #            puts "to generate one run: rails generate symmetric-encryption:config\n\n"
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
symmetric-encryption-0.1.1 lib/symmetric/railtie.rb
symmetric-encryption-0.1.0 lib/symmetric/railtie.rb