I’m writing a custom resource and I would like to pass a block to it (just as in ruby_block). I cannot find how to do this.
Custom resource properties only take ruby classes
String
Integer
Hash
Boolean
Array
https://docs.chef.io/dsl_custom_resource.html#ruby-type
You might be able to create a library instead, but that sounds overly complex.
The simple-but-old-school way looks like this:
def myprop(&block)
set_or_return(:myprop, block, {})
end
The new-and-fancy way is to make a Property subclass that overrides the emit_dsl method to do basically the same thing.
Works like a charm, thanks.