class MultiPassword
Constants
- VERSION
Attributes
options[R]
strategy[R]
Public Class Methods
configure(&block)
click to toggle source
Calls superclass method
# File lib/multi_password.rb, line 34 def self.configure(&block) super.tap do new(algorithm: config.default_algorithm, options: config.default_options) end end
new(algorithm: config.default_algorithm, options: config.default_options)
click to toggle source
# File lib/multi_password.rb, line 40 def initialize(algorithm: config.default_algorithm, options: config.default_options) @strategy = registers.fetch(algorithm).new @options = @strategy.validate_options(options) rescue KeyError raise AlgorithmNotRegistered.new(algorithm) end
register(algorithm, klass)
click to toggle source
# File lib/multi_password.rb, line 19 def self.register(algorithm, klass) if registers[algorithm] Warning.warn <<-MSG [MultiPassword] #{algorithm} is already registered by #{registers[algorithm]} but is overwritten by #{klass} in: #{caller.first} MSG end registers[algorithm] = klass end
registers()
click to toggle source
# File lib/multi_password.rb, line 15 def self.registers @registers end
unregister(algorithm)
click to toggle source
# File lib/multi_password.rb, line 30 def self.unregister(algorithm) registers.delete(algorithm) end
Public Instance Methods
create(password)
click to toggle source
# File lib/multi_password.rb, line 47 def create(password) strategy.create(password, options) end
verify(password, encrypted_password)
click to toggle source
# File lib/multi_password.rb, line 51 def verify(password, encrypted_password) strategy.verify(password, encrypted_password) end
Private Instance Methods
config()
click to toggle source
# File lib/multi_password.rb, line 59 def config self.class.config end
registers()
click to toggle source
# File lib/multi_password.rb, line 63 def registers self.class.registers end