diff options
author | elijah <elijah@riseup.net> | 2015-05-05 15:49:07 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2015-05-05 15:49:07 -0700 |
commit | 6c6b5a88f18f714924530d64486cb88c02bd7ee4 (patch) | |
tree | 3a663822de4c279da8287db04f0a42cfb2c407fb /lib/leap_cli/config/secrets.rb | |
parent | 51195b20531c4dcdf6a76e6a9a8ef7a771cf76be (diff) | |
parent | 61fdf41087b480db12720df5d5beadd32992475a (diff) |
Merge branch 'develop'
Conflicts:
lib/leap_cli/commands/db.rb
lib/leap_cli/commands/vagrant.rb
Diffstat (limited to 'lib/leap_cli/config/secrets.rb')
-rw-r--r-- | lib/leap_cli/config/secrets.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/leap_cli/config/secrets.rb b/lib/leap_cli/config/secrets.rb index 366ffd3..184d11d 100644 --- a/lib/leap_cli/config/secrets.rb +++ b/lib/leap_cli/config/secrets.rb @@ -13,18 +13,29 @@ module LeapCli; module Config @discovered_keys = {} end - # we can't use fetch() or get(), since those already have special meanings - def retrieve(key, environment=nil) - self.fetch(environment||'default', {})[key.to_s] - end + # we can't use fetch() or get(), since those already have special meanings + def retrieve(key, environment) + self.fetch(environment, {})[key.to_s] + end + + def set(*args, &block) + if block_given? + set_with_block(*args, &block) + else + set_without_block(*args) + end + end + + def set_without_block(key, value, environment) + set_with_block(key, environment) {value} + end - def set(key, value, environment=nil) - environment ||= 'default' + def set_with_block(key, environment, &block) key = key.to_s @discovered_keys[environment] ||= {} @discovered_keys[environment][key] = true self[environment] ||= {} - self[environment][key] ||= value + self[environment][key] ||= yield end # |