HyperMe
HyperMe

Reputation: 13

Chef. Can i override library method in wrapper-cookbook?

Example: a - community cookbook, b - wrapper cookbook

a/libraries/default.rb:

module Path
  def path
    '/var/'
  end

  def other_method; end
  ...
end

This module included in a-cookbook resource. a/resources/default.rb:

include Path
...
a = path
b = other_method
...

I want to override path method in wrapper cookbook with:

b/libraries/default.rb:

module Path
  def path
    '/usr/'
  end
end

Upvotes: 1

Views: 507

Answers (1)

coderanger
coderanger

Reputation: 54211

Yes, code in libraries/ is just run as-is so all the normal Ruby rules about monkey patching apply.

Upvotes: 1

Related Questions