Directory

class
Superclass
Mongrel2::Config( :directory )

Mongrel2 Directory (Dir) configuration class

Public Instance Methods

anchor
validate()

Sequel validation callback: add errors if the record is invalid.

# File lib/mongrel2/config/directory.rb, line 17
def validate
        self.validate_base
        self.validate_index_file
        self.validate_default_ctype
        self.validate_cache_ttl
end

Protected Instance Methods

anchor
validate_base()

Validate the 'base' directory which will be served.

# File lib/mongrel2/config/directory.rb, line 30
def validate_base
        if self.base
                if self.base.start_with?( '/' )
                        errmsg = "[%p]: shouldn't start with '/'; that will fail when not in chroot." %
                                [ self.base ]
                        self.log.error( 'base ' + errmsg )
                        self.errors.add( :base, errmsg )
                end

                unless self.base.end_with?( '/' )
                        errmsg = "[%p]: must end with '/' or it won't work right." %
                                [ self.base ]
                        self.log.error( 'base ' + errmsg )
                        self.errors.add( :base, errmsg )
                end
        else
                errmsg = "missing or nil"
                self.log.error( 'base ' + errmsg )
                self.errors.add( :base, errmsg )
        end
end
anchor
validate_cache_ttl()

Validate the cache TTL if one is set.

# File lib/mongrel2/config/directory.rb, line 66
def validate_cache_ttl
        if self.cache_ttl && Integer( self.cache_ttl ) < 0
                errmsg = "[%p]: not a positive Integer" % [ self.cache_ttl ]
                self.log.error( 'cache_ttl' + errmsg )
                self.errors.add( :cache_ttl, errmsg )
        end
end
anchor
validate_default_ctype()

Validate the index file attribute.

# File lib/mongrel2/config/directory.rb, line 60
def validate_default_ctype
        self.validates_presence( :default_ctype, :message => "must not be nil" )
end
anchor
validate_index_file()

Validate the 'index_file' attribute.

# File lib/mongrel2/config/directory.rb, line 54
def validate_index_file
        self.validates_presence( :index_file, :message => "must not be nil" )
end