NAME

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

SYNOPSIS

DBIx::DataModel::Meta::Utils->define_class(
  name    => $class_name,
  isa     => \@parents,
  metadm  => $meta_instance,
);

DBIx::DataModel::Meta::Utils->define_method(
  class          => $class_name,
  name           => $method_name,
  body           => $method_body,
  check_override => $toggle,
);

DBIx::DataModel::Meta::Utils->define_readonly_accessors(
  $class_name => @accessor_names
);

DESCRIPTION

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

METHODS

define_class

DBIx::DataModel::Meta::Utils->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

DBIx::DataModel::Meta::Utils->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

DBIx::DataModel::Meta::Utils->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}}.