Class: Passlib::Context
- Inherits:
-
Object
- Object
- Passlib::Context
- Includes:
- Passlib::Configuration::Context
- Defined in:
- lib/passlib/context.rb
Overview
An isolated configuration context for creating and verifying password hashes.
A Context bundles a Configuration with the full Passlib::Configuration::Context interface (load, create, verify, etc.), letting different parts of an application use different algorithms or settings independently without touching the global Passlib configuration.
By default a new context inherits the global Passlib configuration as its parent, so any option not explicitly overridden falls back to the global setting. Pass another context or configuration as the first argument to inherit from that instead.
Instance Method Summary collapse
-
#initialize(input = nil, **options) ⇒ Context
constructor
Creates a new context.
Methods included from Passlib::Configuration::Context
#configuration, #configuration=, #configure, #create, #load, #upgrade, #upgrade?, #verify
Constructor Details
#initialize ⇒ Context #initialize(parent) ⇒ Context #initialize(**options) ⇒ Context #initialize(parent, **options) ⇒ Context
Creates a new context.
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/passlib/context.rb', line 57 def initialize(input = nil, **) @base_config = nil case input when Passlib::Configuration::Context then @base_config = input.config when Passlib::Configuration then @base_config = input when Hash then @configuration = Passlib::Configuration.new(base_config, input) when nil else raise ArgumentError, "invalid context input: #{input.inspect}" end config.apply() end |