diff options
author | Luke Kanies <luke@madstop.com> | 2009-02-10 14:59:18 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2009-02-10 16:02:52 -0600 |
commit | 0e491591d2ab88938f9b127dd8c26033e817eb1a (patch) | |
tree | 68817b41ad6a90658412956bb5070cff83b787d6 /lib | |
parent | b22d148e6d6eb36c9b02a58dc0c04c9650d5207b (diff) | |
download | puppet-0e491591d2ab88938f9b127dd8c26033e817eb1a.tar.gz puppet-0e491591d2ab88938f9b127dd8c26033e817eb1a.tar.xz puppet-0e491591d2ab88938f9b127dd8c26033e817eb1a.zip |
Cleaning up the AST::Resource code a bit
Mostly renaming 'obj' to 'resource', since the whole
'obj' thing is a holdover from before we had the
term 'resource'.
Also pulling a bit of code out of a loop, since it
didn't need to be there.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/parser/ast/resource.rb | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb index 802410b20..eb0bdeac4 100644 --- a/lib/puppet/parser/ast/resource.rb +++ b/lib/puppet/parser/ast/resource.rb @@ -18,34 +18,35 @@ class Resource < AST::ResourceReference param.safeevaluate(scope) } - objtitles = @title.safeevaluate(scope) + resource_titles = @title.safeevaluate(scope) # it's easier to always use an array, even for only one name - unless objtitles.is_a?(Array) - objtitles = [objtitles] + unless resource_titles.is_a?(Array) + resource_titles = [resource_titles] end - objtype = qualified_type(scope) + resource_type = qualified_type(scope) + + # We want virtual to be true if exported is true. We can't + # just set :virtual => self.virtual in the initialization, + # because sometimes the :virtual attribute is set *after* + # :exported, in which case it clobbers :exported if :exported + # is true. Argh, this was a very tough one to track down. + exp = self.exported || scope.resource.exported? + virt = self.virtual || scope.resource.virtual? || exp # This is where our implicit iteration takes place; if someone # passed an array as the name, then we act just like the called us # many times. - objtitles.flatten.collect { |objtitle| + resource_titles.flatten.collect { |resource_title| exceptwrap :type => Puppet::ParseError do - exp = self.exported || scope.resource.exported? - # We want virtual to be true if exported is true. We can't - # just set :virtual => self.virtual in the initialization, - # because sometimes the :virtual attribute is set *after* - # :exported, in which case it clobbers :exported if :exported - # is true. Argh, this was a very tough one to track down. - virt = self.virtual || scope.resource.virtual? || exp - obj = Puppet::Parser::Resource.new( - :type => objtype, - :title => objtitle, + resource = Puppet::Parser::Resource.new( + :type => resource_type, + :title => resource_title, :params => paramobjects, :file => self.file, :line => self.line, - :exported => exp, + :exported => self.exported, :virtual => virt, :source => scope.source, :scope => scope @@ -53,11 +54,11 @@ class Resource < AST::ResourceReference # And then store the resource in the compiler. # At some point, we need to switch all of this to return - # objects instead of storing them like this. - scope.compiler.add_resource(scope, obj) - obj + # resources instead of storing them like this. + scope.compiler.add_resource(scope, resource) + resource end - }.reject { |obj| obj.nil? } + }.reject { |resource| resource.nil? } end # Set the parameters for our object. |