summaryrefslogtreecommitdiff
path: root/lib/leap_cli/config/macros.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-05-22 00:01:04 -0700
committerelijah <elijah@riseup.net>2014-05-22 00:01:04 -0700
commita327a0544bb725c668b7bca5bf6618c40a9c9cd2 (patch)
tree2ebaafb3d46aeab8352384c89cb17fe1f7487656 /lib/leap_cli/config/macros.rb
parent300e794099ca2c402618e7f17b7279ad6b6f34c5 (diff)
added 'try {}' macro.
Diffstat (limited to 'lib/leap_cli/config/macros.rb')
-rw-r--r--lib/leap_cli/config/macros.rb11
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