def find_resource(type, name, action = nil)
      resource_collection.all_resources.reverse_each.find do |resource|
        resource.declared_type == type.to_sym && (name === resource.identity || name === resource.name) && (action.nil? || resource.performed_action?(action))
      end
    end
def find_resource(type, name, action = nil)
      resource_collection.all_resources.reverse_each.find do |resource|
        resource.declared_type == type.to_sym && (name === resource.identity || name === resource.name) && (action.nil? || resource.performed_action?(action))
      end
    end
Find the resource with the declared type and resource name, and optionally match a performed action.

 If multiples match it returns the last (which more or less matches the chef last-inserter-wins semantics)

 @example Find a template at `/etc/foo`
   chef_run.find_resource(:template, '/etc/foo') #=> #<Chef::Resource::Template>


 @param [Symbol] type
   The type of resource (sometimes called `resource_name`) such as `file`
   or `directory`.
 @param [String, Regexp] name
   The value of the name attribute or identity attribute for the resource.
 @param [Symbol] action
   (optional) match only resources that performed the action.

 @return [Chef::Resource, nil]
   The matching resource, or nil if one is not found