Multiple only_if inside a Ruby_block


#1

Is having multiple only_if or mix of only_if and not_if inside a Ruby_block supported?

 ruby_block 'do something' do
   block do
   ....
   end
   only_if {}
   not_if {}
 end

What would be the ordering logic here?


#2

All only_if and not_if guards are evaluated and they must all "pass". You should probably avoid doing anything crazy that requires passing state between the guards, but FWIW they are stored and evaluated in the order you wrote them.


#3

Thank you very much. I intend to use only_if and not_if to validate something like File.exists and note attribute. Should that be fine?


#4

Yes, make sure to understand lazy evaluation if you need it