module Vault::Rails::Configurable

Public Instance Methods

application() click to toggle source

The name of the Vault::Rails application.

@raise [RuntimeError]

if the application has not been set

@return [String]

# File lib/vault/rails/configurable.rb, line 15
def application
  if defined?(@application) && !@application.nil?
    return @application
  end
  if ENV.has_key?("VAULT_RAILS_APPLICATION")
    return ENV["VAULT_RAILS_APPLICATION"]
  end
  raise RuntimeError, "Must set `Vault::Rails#application'!"
end
application=(val) click to toggle source

Set the name of the application.

@param [String] val

# File lib/vault/rails/configurable.rb, line 28
def application=(val)
  @application = val
end
default_role_name() click to toggle source

Gets the default role name.

@return [String]

# File lib/vault/rails/configurable.rb, line 135
def default_role_name
  @default_role_name
end
default_role_name=(val) click to toggle source

Sets the default role to use with various plugins.

@param [String] val

# File lib/vault/rails/configurable.rb, line 142
def default_role_name=(val)
  @default_role_name = val
end
enabled=(val) click to toggle source

Sets whether Vault is enabled. Users can set this in an initializer depending on their Rails environment.

@example

Vault.configure do |vault|
  vault.enabled = Rails.env.production?
end

@return [true, false]

# File lib/vault/rails/configurable.rb, line 57
def enabled=(val)
  @enabled = !!val
end
enabled?() click to toggle source

Whether the connection to Vault is enabled. The default value is ‘false`, which means vault-rails will perform in-memory encryption/decryption and not attempt to talk to a real Vault server. This is useful for development and testing.

@return [true, false]

# File lib/vault/rails/configurable.rb, line 38
def enabled?
  if defined?(@enabled) && !@enabled.nil?
    return @enabled
  end
  if ENV.has_key?("VAULT_RAILS_ENABLED")
    return (ENV["VAULT_RAILS_ENABLED"] == "true")
  end
  return false
end
in_memory_warnings_enabled=(val) click to toggle source

Sets whether warnings about in-memory ciphers are enabled. Users can set this in an initializer depending on their Rails environment.

@example

Vault.configure do |vault|
  vault.in_memory_warnings_enabled = !Rails.env.test?
end

@return [true, false]

# File lib/vault/rails/configurable.rb, line 83
def in_memory_warnings_enabled=(val)
  @in_memory_warnings_enabled = val
end
in_memory_warnings_enabled?() click to toggle source

Whether warnings about in-memory ciphers are enabled. The default value is ‘true`, which means vault-rails will log a warning for every attempt to encrypt or decrypt using an in-memory cipher. This is useful for development and testing.

@return [true, false]

# File lib/vault/rails/configurable.rb, line 67
def in_memory_warnings_enabled?
  if !defined?(@in_memory_warnings_enabled) || @in_memory_warnings_enabled.nil?
    return true
  end
  return @in_memory_warnings_enabled
end
retry_attempts() click to toggle source

Gets the number of retry attempts.

@return [Fixnum]

# File lib/vault/rails/configurable.rb, line 90
def retry_attempts
  @retry_attempts ||= 0
end
retry_attempts=(val) click to toggle source

Sets the number of retry attempts. Please see the Vault documentation for more information.

@param [Fixnum] val

# File lib/vault/rails/configurable.rb, line 98
def retry_attempts=(val)
  @retry_attempts = val
end
retry_base() click to toggle source

Gets the number of retry attempts.

@return [Fixnum]

# File lib/vault/rails/configurable.rb, line 105
def retry_base
  @retry_base ||= Vault::Defaults::RETRY_BASE
end
retry_base=(val) click to toggle source

Sets the retry interval. Please see the Vault documentation for more information.

@param [Fixnum] val

# File lib/vault/rails/configurable.rb, line 113
def retry_base=(val)
  @retry_base = val
end
retry_max_wait() click to toggle source

Gets the retry maximum wait.

@return [Fixnum]

# File lib/vault/rails/configurable.rb, line 120
def retry_max_wait
  @retry_max_wait ||= Vault::Defaults::RETRY_MAX_WAIT
end
retry_max_wait=(val) click to toggle source

Sets the maximum amount of time for a single retry. Please see the Vault documentation for more information.

@param [Fixnum] val

# File lib/vault/rails/configurable.rb, line 128
def retry_max_wait=(val)
  @retry_max_wait = val
end