Badger::Data::Type

NAME

Top Close Open

Badger::Data::Type - base class for data types

DESCRIPTION

Top Close Open

This module implements a base class for data types.

CONFIGURATION OPTIONS

Top Close Open

name

Top Close Open

An optional name for the data type.

namespace

Top Close Open

An optional namespace for the data type.

base

Top Close Open

An optional base data type.

facets

Top Close Open

An optional list of validation facets.

METHODS

Top Close Open

The following methods are defined in addition to those inherited from the Badger::Base base class.

init()

Top Close Open

This is aliased to the init_type() method.

init_type($config)

Top Close Open

This is the initialisation method for a data type. It is called automatically when a data type object is created via the new() method inherited from the Badger::Base base class.

name()

Top Close Open

Returns the name of the data type as specified via the name configuration option. If no name was specified then an automatically generated name is returned based on the class name with the Badger::Data::Type prefix removed and all :: sequences replaced with periods, e.g. a data type Badger::Data::Type::Foo::Bar would yield a name of Foo.Bar.

namespace()

Top Close Open

Returns the namespace for the data type, or undef is none is defined.

base()

Top Close Open

Returns the base data type, or undef is none is defined.

facets()

Top Close Open

Returns a reference to a list of validation facets defined for the data type.

simple()

Top Close Open

This constant method always returns the value 0. Subclasses representing simple data types should re-define this to return the value 1.

complex()

Top Close Open

This constant method always returns the value 0. Subclasses representing complex data types should re-define this to return the value 1.

constrain($facet, @args)

Top Close Open

Applies a new validation facet to the data type.

validate($value_ref)

Top Close Open

Validates the value passed by reference as the first argument. It calls the validate() method of each of the validation facets in turn.

AUTHOR

Top Close Open

Andy Wardley http://wardley.org/

COPYRIGHT

Top Close Open

Copyright (C) 2008-2012 Andy Wardley. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Fork Me on Github