summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2012-01-31 15:53:52 -0800
committerBryan McLellan <btm@loftninjas.org>2012-01-31 15:53:52 -0800
commitfc82b6b6c3d10416194ad0a12cda14aa6f6e6b30 (patch)
tree0f6ffbdf05c40009536e1ef0df3d2e5da9719f87
parentf73211f86616918df2862152ab92778c6917b78b (diff)
downloadchef-fc82b6b6c3d10416194ad0a12cda14aa6f6e6b30.tar.gz
create after_created hook for Chef::Resource
-rw-r--r--chef/lib/chef/mixin/recipe_definition_dsl_core.rb4
-rw-r--r--chef/lib/chef/resource.rb5
2 files changed, 9 insertions, 0 deletions
diff --git a/chef/lib/chef/mixin/recipe_definition_dsl_core.rb b/chef/lib/chef/mixin/recipe_definition_dsl_core.rb
index 71f0b4fadd..cf89600654 100644
--- a/chef/lib/chef/mixin/recipe_definition_dsl_core.rb
+++ b/chef/lib/chef/mixin/recipe_definition_dsl_core.rb
@@ -70,8 +70,12 @@ class Chef
resource.source_line = caller[0]
# Determine whether this resource is being created in the context of an enclosing Provider
resource.enclosing_provider = self.is_a?(Chef::Provider) ? self : nil
+ # Evaluate resource attribute DSL
resource.instance_eval(&block) if block
+ # Run optional resource hook
+ resource.after_created
+
run_context.resource_collection.insert(resource)
resource
end
diff --git a/chef/lib/chef/resource.rb b/chef/lib/chef/resource.rb
index 32b0e25ddc..0d66618402 100644
--- a/chef/lib/chef/resource.rb
+++ b/chef/lib/chef/resource.rb
@@ -500,6 +500,11 @@ F
resource
end
+ # Hook to allow a resource to run specific code after creation
+ def after_created
+ nil
+ end
+
extend Chef::Mixin::ConvertToClassName
def self.attribute(attr_name, validation_opts={})