Method: Itamae::RecipeChildren#find_resource_by_description

Defined in:
lib/itamae/recipe_children.rb

#find_resource_by_description(desc) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/itamae/recipe_children.rb', line 5

def find_resource_by_description(desc)
  # desc is like 'resource_type[name]'
  resources.find do |resource|
    type, name = Itamae::Resource.parse_description(desc)
    resource.resource_type == type && resource.resource_name == name
  end.tap do |resource|
    unless resource
      raise NotFoundError, "'#{desc}' resource is not found."
    end
  end
end