Ensurable - Is it possible to wire exists? method to anything other than present or absent?

asked 2018-01-31 03:17:52 -0500

I have passed a block to the ensurable method and define acceptable property values as well as the methods of the provider that are to be called. I understand that present and absent property depend on the result of the exist? method and depending on it they will be called/not called. However, I have a case where I also want other actions (my_action1, my_action2) to also depend on exists? result, is it possible to achieve that?

ensurable do
  newvalue(:present) do
    provider.create
  end

  newvalue(:absent) do
    provider.destroy
  end

  newvalue(:my_action1) do
    provider.my_action1
  end

  newvalue(:my_action2) do
    provider.my_action2
  end
end
edit retag flag offensive close merge delete