diff options
author | danielsdeleo <dan@opscode.com> | 2013-05-27 12:31:40 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-05-29 11:32:22 -0700 |
commit | 1a4d285a9977c182a372c3fb22469846d68e1d44 (patch) | |
tree | 03ba0164a751f86ca0c3ac2c4075aefd5f168125 /lib/chef/mixin/template.rb | |
parent | 7761abd2ef185acca93c9330db235f6704689ae4 (diff) | |
download | chef-1a4d285a9977c182a372c3fb22469846d68e1d44.tar.gz |
Add inline doc for TemplateContext
Diffstat (limited to 'lib/chef/mixin/template.rb')
-rw-r--r-- | lib/chef/mixin/template.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb index 8a0cb060f6..4225f2ea14 100644 --- a/lib/chef/mixin/template.rb +++ b/lib/chef/mixin/template.rb @@ -32,8 +32,12 @@ class Chef module ChefContext end - # TODO: extract to file - # TODO: docs + # == TemplateContext + # TemplateContext is the base context class for all templates in Chef. It + # defines user-facing extensions to the base Erubis::Context to provide + # enhanced features. Individual instances of TemplateContext can be + # extended to add logic to a specific template. + # class TemplateContext < Erubis::Context include ChefContext @@ -49,6 +53,9 @@ class Chef # USER FACING API ### + # Returns the current node object, or raises an error if it's not set. + # Provides API consistency, allowing users to reference the node object + # by the bare `node` everywhere. def node return @node if @node raise "Could not find a value for node. If you are explicitly setting variables in a template, " + @@ -101,6 +108,10 @@ class Chef end end + # Collects instance variables set on the current object as a Hash + # suitable for creating a new TemplateContext. Instance variables that + # are only valid for this specific instance are omitted from the + # collection. def _public_instance_variables all_ivars = instance_variables all_ivars.delete(:@_extension_modules) |