diff options
author | elijah <elijah@riseup.net> | 2014-05-22 00:01:04 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2014-05-22 00:01:04 -0700 |
commit | a327a0544bb725c668b7bca5bf6618c40a9c9cd2 (patch) | |
tree | 2ebaafb3d46aeab8352384c89cb17fe1f7487656 /lib/leap_cli/config/macros.rb | |
parent | 300e794099ca2c402618e7f17b7279ad6b6f34c5 (diff) |
added 'try {}' macro.
Diffstat (limited to 'lib/leap_cli/config/macros.rb')
-rw-r--r-- | lib/leap_cli/config/macros.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/leap_cli/config/macros.rb b/lib/leap_cli/config/macros.rb index 2eabdd0..30381ee 100644 --- a/lib/leap_cli/config/macros.rb +++ b/lib/leap_cli/config/macros.rb @@ -415,5 +415,16 @@ module LeapCli; module Config end end + # + # wrap something that might fail in `try`. e.g. + # + # "= try{ nodes[:services => 'tor'].first.ip_address } " + # + def try(&block) + yield + rescue NoMethodError + nil + end + end end; end |