NAME

T2::Schema - Tangram Schemas, suitable for putting in a Tangram Store

SYNOPSIS

use T2::Schema;

my $schema = T2::Schema->load("site"); $schema->compile();

new Object();

DESCRIPTION

METHODS

T2::Schema->load("site"[, $source])

This is actually a constructor :-).

Load the schema for site and return it.

$source, if given, may be a Tangram::Storage object - in which case it is assumed to be the schema database. If missing, T2::Storage->connect() is used to obtain a handle to the schema database.

$source may also be the correct Schema object, for convenience. In this case it is returned unchanged.

$schema->read_file("site" | $filename)

This is actually a constructor :-).

Load a dumped schema for site and returns it. $filename, if given, may be the name of a file to use, or the site name (in which case, the file name is assumed to be etc/site.t2.

$schema->compile

Loads all of the classes in the schema in to memory.

Tries to use on-disk versions rather than generating the in-memory object & then compiling it.

The idea is that Class::Tangram version 2 uses `Class' objects as input bread and butter rather than `schema' structures. This should eliminate the necessity for a huge `eval'.

This interface is deprecated in favour of using $schema->generator

$schema->generator

Returns a Class::Tangram::Generator object that is valid for this Schema.

$schema->schema_raw

Returns the data structure that is fed into Tangram::Schema->new().

Note that Tangram performs various in-place edits of this data structure. So don't go assuming too much about it.

$schema->schema

$schema->schema_cooked

Generates a Tangram Schema for this Schema, or returns the one that was already generated. Use $schema->set_schema(undef) to force a re-generation of the Tangram Schema structure.

$schema->storage

Returns the Tangram Storage class associated with this Schema. Possibly connecting to the database.

$schema->class($name)

Returns the class definition for class $name.

Croaks if there is no class $name.

$schema->class_exists($name)

Returns the class definition for class $name.

Returns undef if no such class is found.

$schema->class_or_new($name)

Returns the class definition for class $name.

Returns a new class if no such class is found.

add_class_from_schema($name => $schema)

Adds a Class object to this schema, gleaning information from $schema, which you perhaps found in $YourClass::schema.

$schema->sorted_classes

Returns the classes in inheritance first order. Actually this function is pretty redundant, you can just call sort $schema->classes, but this implementation takes a different approach.

$schema->traverse(sub { })

Traverses over every object in the schema, setting $_[0] to the item.

T2::Schema->self_schema()

Returns a structure of T2::Schema and related objects that represents the schema of the T2::Schema modules.

3 POD Errors

The following errors were encountered while parsing the POD:

Around line 160:

You forgot a '=back' before '=head2'

Around line 490:

'=item' outside of any '=over'

Around line 538:

You forgot a '=back' before '=head2'