Class: Clandestine::Commands::Add
- Inherits:
-
Object
- Object
- Clandestine::Commands::Add
- Defined in:
- lib/clandestine/commands/add.rb
Instance Method Summary collapse
- #add ⇒ Object
-
#initialize(safe_password, key) ⇒ Add
constructor
A new instance of Add.
Constructor Details
#initialize(safe_password, key) ⇒ Add
Returns a new instance of Add.
12 13 14 15 16 |
# File 'lib/clandestine/commands/add.rb', line 12 def initialize(safe_password, key) raise ClandestineError.new 'Missing required key argument' unless key @safe_password = safe_password @key = key.to_sym end |
Instance Method Details
#add ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/clandestine/commands/add.rb', line 18 def add Safe.new(safe_password).open do |safe| if !safe.exists?(key) safe.add(key, PasswordGenerator.random_password) else false end end end |