NAME
Association - abstract base class for Association types
SYNOPSIS
my
$assoc
= Oryx::Association->new(
$meta
,
$source
);
$assoc
->source;
# association from
$assoc
->class;
# association to
$assoc
->role;
# name of association accessor
$assoc
->type;
# Array, Hash, Reference etc.
$assoc
->constraint;
# Aggregate or Composition
$assoc
->is_weak;
$assoc
->update_backrefs;
$assoc
->link_table;
DESCRIPTION
This module represents an abstract base class for Oryx association types.
METHODS
- new( $meta, $source )
-
The constructor returns the correct instance of the correct subclass based on the
type
field of the$meta
hashref passed as an argument. The$source
argument is the name of the class in which this association is defined (see Oryx::Class) - create
-
Abstract (see implementing subclasses)
- retrieve
-
Abstract (see implementing subclasses)
- update
-
Abstract (see implementing subclasses)
- delete
-
Abstract (see implementing subclasses)
- search
-
Abstract (see implementing subclasses)
- construct
-
Abstract (see implementing subclasses)
- source
-
Simple accessor to the source class in which this association is defined.
- class
-
Simple accessor to the target class with which the source class has an associtation.
- role
-
Simple accessor to the association accessor name defined in the source class. Defaults to the target class' table name.
- type
-
Reference, Array or Hash... defaults to Reference.
- is_weak
-
Simple accessor to the
is_weak
meta-attribute. This is used for stopping Reference association types from creating a column in the target class for storing a reverse association. - constraint
-
Simple accessor to the
constraint
meta-attribute. Values are: Aggregate or Composition ... Aggregate is the default, Composition causes deletes to cascade. - update_backrefs
-
Updates reverse Reference associations.
NOTE: Currently, reverse associations are made up of two unidirectional associations... link tables are therefore not shared. This will be fixed.
- link_table
-
Returns a name for the link table for this association. Not relevant for Reference associations as these don't require a link table.
This is just a shortcut for:
$self
->source->table.
'_'
.
$self
->role.
'_'
.
$self
->class->table
Override for custom association types as needed.
AUTHOR
Richard Hundt <richard NO SPAM AT protea-systems.com>
THANKS TO
Andrew Sterling Hanencamp
LICENCE
This module is free software and may be used under the same terms as Perl itself.