Sha256: 9157c7998e8c3f933a4a46d346d5834dee56aea3c268489010b7882a873fbcef

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

class Puppet::Parser::AST
    # A statement syntactically similar to an ObjectDef, but uses a
    # capitalized object type and cannot have a name.  
    class TypeDefaults < AST::Branch
        attr_accessor :type, :params

        def each
            [@type,@params].each { |child| yield child }
        end

        # As opposed to ObjectDef, this stores each default for the given
        # object type.
        def evaluate(hash)
            scope = hash[:scope]
            type = @type.safeevaluate(:scope => scope)
            params = @params.safeevaluate(:scope => scope)

            begin
                scope.setdefaults(type.downcase,params)
            rescue Puppet::ParseError => except
                except.line = self.line
                except.file = self.file
                raise except
            rescue => detail
                error = Puppet::ParseError.new(detail)
                error.line = self.line
                error.file = self.file
                error.backtrace = detail.backtrace
                raise error
            end
        end

        def tree(indent = 0)
            return [
                @type.tree(indent + 1),
                ((@@indline * 4 * indent) + self.typewrap(self.pin)),
                @params.tree(indent + 1)
            ].join("\n")
        end

        def to_s
            return "%s { %s }" % [@type,@params]
        end
    end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-0.13.6 lib/puppet/parser/ast/typedefaults.rb
puppet-0.18.4 lib/puppet/parser/ast/typedefaults.rb
puppet-0.16.0 lib/puppet/parser/ast/typedefaults.rb