Skip to content

Commit

Permalink
create after_created hook for Chef::Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
btm committed Jan 31, 2012
1 parent f73211f commit fc82b6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chef/lib/chef/mixin/recipe_definition_dsl_core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ def method_missing(method_symbol, *args, &block)
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
Expand Down
5 changes: 5 additions & 0 deletions chef/lib/chef/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ def self.json_create(o)
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={})
Expand Down

0 comments on commit fc82b6b

Please sign in to comment.