Skip to content

Instantly share code, notes, and snippets.

@charleseff
Created January 9, 2014 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charleseff/8327591 to your computer and use it in GitHub Desktop.
Save charleseff/8327591 to your computer and use it in GitHub Desktop.
Is there a better way to do this?
$attrs_first = {
command => "/foo",
}
if $condition {
$more_attrs = {require => Class['bar']}
$attrs = merge($attrs_first, $more_attrs)
} else {
$attrs = $attrs_first
}
$resource = { "something" => $attrs }
create_resources(exec, $resource)
@charleseff
Copy link
Author

compare to ruby:

{ command: '/foo'}.tap{|f| f.merge!(require: "class['bar']") if condition }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment