diff options
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 |