Method: Chef::Exceptions::MultipleDscResourcesFound#initialize

Defined in:
lib/chef/exceptions.rb

#initialize(resources_found) ⇒ MultipleDscResourcesFound

Returns a new instance of MultipleDscResourcesFound.



531
532
533
534
535
536
537
538
539
540
541
# File 'lib/chef/exceptions.rb', line 531

def initialize(resources_found)
  @resources_found = resources_found
  matches_info = @resources_found.each do |r|
    if r["Module"].nil?
      "Resource #{r["Name"]} was found in #{r["Module"]["Name"]}"
    else
      "Resource #{r["Name"]} is a binary resource"
    end
  end
  super "Found multiple resources matching #{matches_info[0]["Module"]["Name"]}:\n#{(matches_info.map { |f| f["Module"]["Version"] }).uniq.join("\n")}"
end