Search code examples
chef-infralwrp

Private method in custom resource does not work


I would like to do similar thing using Custom Resource: Here is provider code (LWRP) which works

action :create
  my_private_method(a)
  my_private_method(b)
end

private
def my_private_method(p)
  (some code)
end

If I make similar code using Custom Resource, and define private method, chef-client run fails with error:

No resource or method 'my_private_method' for 'LWRP resource ...

What is the syntax to declare/invoke private method in Custom Resource?


Solution

  • new_resource.send(:my_private_method, a), and because of this making things private isn't hugely recommended.