NAME

DBIx::DataModel::Meta::Utils - Utility functions for DBIx::DataModel metaclasses

SYNOPSIS

use DBIx::DataModel::Meta::Utils qw/define_class define_method define_readonly_accessors does/;

define_class(
  name    => $class_name,
  isa     => \@parents,
  metadm  => $meta_instance,
);

define_method(
  class          => $class_name,
  name           => $method_name,
  body           => $method_body,
  check_override => $toggle,
);

define_readonly_accessors(
  $class_name => @accessor_names
);

DESCRIPTION

A few utility functions for convenience of other DBIx::DataModel::Meta::* subclasses.

METHODS

define_class

define_class(
  name    => $class_name,
  isa     => \@parents,
  metadm  => $meta_instance,
);

Creates a Perl class of the given name, that inherits from classes specified in @parents, and injects into that class a metadm accessor method that will return the given $meta_instance.

define_method

define_method(
  class          => $class_name,
  name           => $method_name,
  body           => $method_body,
  check_override => $toggle,
);

Creates a method $method_name within class $class_name, with $method_body as implementation. If $check_override is true, a warning is issued if the method name conflicts with an inherited method in that class.

define_readonly_accessors

define_readonly_accessors(
  $class_name => @accessor_names
);

Creates a collection of accessor methods within $class_name. Each accessor method returns the value stored in %$self under the same name, i.e. accessor foo returns $self->{foo}. However, if that value is a hashref or arrayref, a shallow copy is returned : for example if $self->{foo} is an arrayref, then the accessor method returns @{$self->{foo}}.

does

See "does()" in SQL::Abstract::More