module Poise::Helpers::DefinedIn

A mixin to track where a resource or provider was defined. This can provide either the filename of the class or the cookbook it was defined in.

@since 2.0.0 @example

class MyProvider < Chef::provider
  include Poise::Helpers::DefinedIn

  def action_create
    template '...' do
      # ...
      cookbook new_resource.poise_defined_in
    end
  end
end

Constants

CALLER_REGEXP

A regex used to parse Ruby's `caller` string syntax. @see poise_defined! @api private

CHEF_LIB_ROOT

Path to the root of Chef's code. @see poise_defined! @api private

POISE_LIB_ROOT

Path to the root of Poise's code. @see poise_defined! @api private

Public Instance Methods

poise_defined_in_cookbook(file=nil) click to toggle source

Wrapper for {.poise_defined_in_cookbook} to pass the run context for you.

@see .poise_defined_in_cookbook @param file [String, nil] Optional file path to check instead of the path

this class was defined in.

@return [String]

# File lib/poise/helpers/defined_in.rb, line 61
def poise_defined_in_cookbook(file=nil)
  self.class.poise_defined_in_cookbook(run_context, file)
end